Skip to content

Commit

Permalink
update yolact, removing Instaboost when evaluating
Browse files Browse the repository at this point in the history
  • Loading branch information
GouMinghao committed Aug 30, 2019
1 parent 49dc945 commit 05a5c06
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
12 changes: 8 additions & 4 deletions yolact/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ pip install instaboost
Integrating InstaBoost into yolact is quite simple.
Only few lines should be modified to put InstaBoost into use.

Only [data/coco.py](data/coco.py) should be changed.
[data/coco.py](data/coco.py), [train.py](train.py) and [eval.py](eval.py) should be changed.

[line 11](data/coco.py#L11) Importing InstaBoost.
[coco.py/line 11](data/coco.py#L11) imports InstaBoost.

[line 115-120](data/coco.py#L115-L120) These lines are originally located at [line 137-144](data/coco.py#L137-L144). They are put here because the InstaBoost function `get_new_data` needs both the annotation and the image.
[coco.py/line 68](data/coco.py#L68) assigns the value of `is_train`.

[line 122](data/coco.py#L122) Run the InstaBoost function and get new image and annotation. Both the variables `target` and `img` are acquired using the official COCO Python API.
[coco.py/line 116-121](data/coco.py#L116-L121) These lines are originally located at [line 139-146](data/coco.py#L137-L144). They are put here because the InstaBoost function `get_new_data` needs both the annotation and the image.

[coco.py/line 123-124](data/coco.py#L123-L124) checks if it's training or evaluating. When training, the program runs the InstaBoost function and gets new image and annotation. Both the variables `target` and `img` are acquired using the official COCO Python API.

[train.py/line 130](train.py#L130) and [train.py/line 134](train.py#L134) assign `True` to the variable of `is_train`.

[eval.py/line](eval.py#L) assigns `False` to the variable of `is_train`.
## Results and models

For your conveinience of evaluation and comparison, we report the evaluation number on COCO val below. In our paper, the numbers are obtained from test-dev.
Expand Down
8 changes: 5 additions & 3 deletions yolact/data/coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ class COCODetection(data.Dataset):

def __init__(self, image_path, info_file, transform=None,
target_transform=COCOAnnotationTransform(),
dataset_name='MS COCO', has_gt=True):
dataset_name='MS COCO', has_gt=True,is_train=True):
# Do this here because we have too many things named COCO
from pycocotools.coco import COCO

self.is_train=is_train
self.root = image_path
self.coco = COCO(info_file)

Expand Down Expand Up @@ -95,7 +96,7 @@ def __len__(self):
def pull_item(self, index):
"""
Args:
index (int): Index
index (int): Indexcolor_cache
Returns:
tuple: Tuple (image, target, masks, height, width, crowd).
target is the object returned by ``coco.loadAnns``.
Expand All @@ -119,7 +120,8 @@ def pull_item(self, index):
assert osp.exists(path), 'Image path does not exist: {}'.format(path)
img = cv2.imread(path)

target, img = get_new_data(target, img, None, background=None)
if self.is_train:
target, img = get_new_data(target, img, None, background=None)

# Separate out crowd annotations. These are annotations that signify a large crowd of
# objects of said class, where there is no annotation for each individual object. Both
Expand Down
2 changes: 1 addition & 1 deletion yolact/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ def print_maps(all_maps):

if args.image is None and args.video is None and args.images is None:
dataset = COCODetection(cfg.dataset.valid_images, cfg.dataset.valid_info,
transform=BaseTransform(), has_gt=cfg.dataset.has_gt)
transform=BaseTransform(), has_gt=cfg.dataset.has_gt,is_train=False)
prep_coco_cats()
else:
dataset = None
Expand Down
4 changes: 2 additions & 2 deletions yolact/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ def train():

dataset = COCODetection(image_path=cfg.dataset.train_images,
info_file=cfg.dataset.train_info,
transform=SSDAugmentation(MEANS))
transform=SSDAugmentation(MEANS),is_train=True)

if args.validation_epoch > 0:
setup_eval()
val_dataset = COCODetection(image_path=cfg.dataset.valid_images,
info_file=cfg.dataset.valid_info,
transform=BaseTransform(MEANS))
transform=BaseTransform(MEANS),is_train=True)

# Parallel wraps the underlying module, but when saving and loading we don't want that
yolact_net = Yolact()
Expand Down

0 comments on commit 05a5c06

Please sign in to comment.