From a2fd294eeb91771a052ee0e09713ab90cb6b888f Mon Sep 17 00:00:00 2001 From: Alexander Goryunov <43528668+agoryuno@users.noreply.github.com> Date: Sat, 2 Sep 2023 14:50:54 +0300 Subject: [PATCH 1/4] if-name protect exec'd code See issue #41 --- adet/data/builtin.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/adet/data/builtin.py b/adet/data/builtin.py index 024e72e..30a2aee 100644 --- a/adet/data/builtin.py +++ b/adet/data/builtin.py @@ -75,24 +75,24 @@ def register_all_coco(root="datasets", voc_size_cfg=37, num_pts_cfg=25): num_pts_cfg ) - -# get the vocabulary size and number of point queries in each instance -# to eliminate blank text and sample gt according to Bezier control points -parser = default_argument_parser() -# add the following argument to avoid some errors while running demo/demo.py -parser.add_argument("--input", nargs="+", help="A list of space separated input images") -parser.add_argument( - "--output", - help="A file or directory to save output visualizations. " - "If not given, will show output in an OpenCV window.", -) -parser.add_argument( - "--opts", - help="Modify config options using the command-line 'KEY VALUE' pairs", - default=[], - nargs=argparse.REMAINDER, +if __name__ == "__main__": + # get the vocabulary size and number of point queries in each instance + # to eliminate blank text and sample gt according to Bezier control points + parser = default_argument_parser() + # add the following argument to avoid some errors while running demo/demo.py + parser.add_argument("--input", nargs="+", help="A list of space separated input images") + parser.add_argument( + "--output", + help="A file or directory to save output visualizations. " + "If not given, will show output in an OpenCV window.", ) -args = parser.parse_args() -cfg = get_cfg() -cfg.merge_from_file(args.config_file) -register_all_coco(voc_size_cfg=cfg.MODEL.TRANSFORMER.VOC_SIZE, num_pts_cfg=cfg.MODEL.TRANSFORMER.NUM_POINTS) + parser.add_argument( + "--opts", + help="Modify config options using the command-line 'KEY VALUE' pairs", + default=[], + nargs=argparse.REMAINDER, + ) + args = parser.parse_args() + cfg = get_cfg() + cfg.merge_from_file(args.config_file) + register_all_coco(voc_size_cfg=cfg.MODEL.TRANSFORMER.VOC_SIZE, num_pts_cfg=cfg.MODEL.TRANSFORMER.NUM_POINTS) From b485d8ac76fb72b1266457f1ab5fe41307eccfba Mon Sep 17 00:00:00 2001 From: Alexander Goryunov <43528668+agoryuno@users.noreply.github.com> Date: Sat, 2 Sep 2023 14:56:26 +0300 Subject: [PATCH 2/4] Update augmentation.py --- adet/data/augmentation.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/adet/data/augmentation.py b/adet/data/augmentation.py index 626385f..132abfd 100644 --- a/adet/data/augmentation.py +++ b/adet/data/augmentation.py @@ -1,14 +1,11 @@ import random -from typing import Tuple -import sys -from PIL import Image import numpy as np from fvcore.transforms import transform as T +from fvcore.transforms.transform import Transform, NoOpTransform from detectron2.data.transforms import RandomCrop, StandardAugInput from detectron2.structures import BoxMode -import torch from detectron2.data.transforms import Augmentation, PadTransform -from fvcore.transforms.transform import Transform, NoOpTransform + def gen_crop_transform_with_instance(crop_size, image_size, instances, crop_box=True): @@ -130,4 +127,4 @@ def get_transform(self, img): # pad_h, pad_w = 32 - ori_h % 32, 32 - ori_w % 32 return PadTransform( 0, 0, pad_w, pad_h, pad_value=0 - ) \ No newline at end of file + ) From 2b5900cfb1103bf609d1e7bdf072afbc2cd91ef5 Mon Sep 17 00:00:00 2001 From: Alexander Goryunov Date: Sat, 2 Sep 2023 15:03:35 +0300 Subject: [PATCH 3/4] Revert "Update augmentation.py" This reverts commit b485d8ac76fb72b1266457f1ab5fe41307eccfba. --- adet/data/augmentation.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/adet/data/augmentation.py b/adet/data/augmentation.py index 132abfd..626385f 100644 --- a/adet/data/augmentation.py +++ b/adet/data/augmentation.py @@ -1,11 +1,14 @@ import random +from typing import Tuple +import sys +from PIL import Image import numpy as np from fvcore.transforms import transform as T -from fvcore.transforms.transform import Transform, NoOpTransform from detectron2.data.transforms import RandomCrop, StandardAugInput from detectron2.structures import BoxMode +import torch from detectron2.data.transforms import Augmentation, PadTransform - +from fvcore.transforms.transform import Transform, NoOpTransform def gen_crop_transform_with_instance(crop_size, image_size, instances, crop_box=True): @@ -127,4 +130,4 @@ def get_transform(self, img): # pad_h, pad_w = 32 - ori_h % 32, 32 - ori_w % 32 return PadTransform( 0, 0, pad_w, pad_h, pad_value=0 - ) + ) \ No newline at end of file From ee0960903915eed33ffc4f4676bc5ebf4f187e1a Mon Sep 17 00:00:00 2001 From: Alexander Goryunov <43528668+agoryuno@users.noreply.github.com> Date: Sat, 2 Sep 2023 15:06:00 +0300 Subject: [PATCH 4/4] Update augmentation.py Removing unused imports. --- adet/data/augmentation.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/adet/data/augmentation.py b/adet/data/augmentation.py index 626385f..cd2e1df 100644 --- a/adet/data/augmentation.py +++ b/adet/data/augmentation.py @@ -1,14 +1,12 @@ import random -from typing import Tuple -import sys -from PIL import Image import numpy as np + from fvcore.transforms import transform as T +from fvcore.transforms.transform import Transform, NoOpTransform + from detectron2.data.transforms import RandomCrop, StandardAugInput from detectron2.structures import BoxMode -import torch from detectron2.data.transforms import Augmentation, PadTransform -from fvcore.transforms.transform import Transform, NoOpTransform def gen_crop_transform_with_instance(crop_size, image_size, instances, crop_box=True): @@ -130,4 +128,4 @@ def get_transform(self, img): # pad_h, pad_w = 32 - ori_h % 32, 32 - ori_w % 32 return PadTransform( 0, 0, pad_w, pad_h, pad_value=0 - ) \ No newline at end of file + )