Skip to content

Commit

Permalink
fix code typos mentioned in #5 and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
MendelXu committed Sep 13, 2021
1 parent 323a06c commit 97d0913
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 62 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This repo is the official implementation of ["End-to-End Semi-Supervised Object

### Partial Labeled Data

We followed STAC[1] to evalutate on 5 different data splits for each settings, and report the average performance of 5 splits. The results are shown in the following:
We followed STAC[1] to evaluate on 5 different data splits for each settings, and report the average performance of 5 splits. The results are shown in the following:

#### 1% labeled data
| Method | mAP| Model Weights |Config Files|
Expand Down
5 changes: 2 additions & 3 deletions configs/soft_teacher/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
unsup_pipeline = [
dict(type="LoadImageFromFile"),
# dict(type="LoadAnnotations", with_bbox=True),
# generate fake labels for data format compability
# generate fake labels for data format compatibility
dict(type="PseudoSamples", with_bbox=True),
dict(
type="MultiBranch", unsup_teacher=strong_pipeline, unsup_student=weak_pipeline
Expand Down Expand Up @@ -256,8 +256,7 @@
custom_hooks = [
dict(type="NumClassCheckHook"),
dict(type="WeightSummary"),
dict(type="MeanTeacher", momentum=0.999, interval=1, warm_up=0),
dict(type="Weighter", steps=[-5000], vals=[4, 0], name="unsup_weight"),
dict(type="MeanTeacher", momentum=0.999, interval=1, warm_up=0)
]
evaluation = dict(type="SubModulesDistEvalHook", interval=4000)
optimizer = dict(type="SGD", lr=0.01, momentum=0.9, weight_decay=0.0001)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
_base_ = "base.py"
_base_ = "soft_teacher_faster_rcnn_r50_caffe_fpn_coco_full_720k.py"
model = dict(
backbone=dict(
depth=101,
init_cfg=dict(checkpoint="open-mmlab://detectron2/resnet101_caffe"),
)
)

data = dict(
samples_per_gpu=8,
workers_per_gpu=8,
train=dict(
sup=dict(
ann_file="data/coco/annotations/instances_train2017.json",
img_prefix="data/coco/train2017/",
),
unsup=dict(
ann_file="data/coco/annotations/instances_unlabeled2017.json",
img_prefix="data/coco/unlabeled2017/",
),
),
sampler=dict(
train=dict(
sample_ratio=[1, 1],
)
),
)

semi_wrapper = dict(
train_cfg=dict(
unsup_weight=2.0,
)
)

lr_config = dict(step=[120000 * 6, 160000 * 6])
runner = dict(_delete_=True, type="IterBasedRunner", max_iters=180000 * 6)
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
_base_ = "base.py"
_base_ = "soft_teacher_faster_rcnn_r50_caffe_fpn_coco_full_720k.py"

data = dict(
samples_per_gpu=8,
workers_per_gpu=8,
train=dict(
sup=dict(
ann_file="data/coco/annotations/instances_train2017.json",
img_prefix="data/coco/train2017/",
),
unsup=dict(
ann_file="data/coco/annotations/instances_unlabeled2017.json",
img_prefix="data/coco/unlabeled2017/",
),
),
sampler=dict(
train=dict(
sample_ratio=[1, 1],
)
),
)

semi_wrapper = dict(
train_cfg=dict(
unsup_weight=2.0,
)
)

lr_config = dict(step=[120000 * 8, 160000 * 8])
runner = dict(_delete_=True, type="IterBasedRunner", max_iters=180000 * 8)
2 changes: 1 addition & 1 deletion ssod/datasets/pipelines/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .formating import *
from .formatting import *
from .rand_aug import *
File renamed without changes.
2 changes: 1 addition & 1 deletion ssod/datasets/pipelines/geo_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Recored the geometric transformation information used in the augmentation in a transformation matrix.
Record the geometric transformation information used in the augmentation in a transformation matrix.
"""
import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion ssod/datasets/pipelines/rand_aug.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def _translate_bboxes(self, results, offset, direction="horizontal"):
min_y = np.maximum(0, min_y + offset)
max_y = np.minimum(h, max_y + offset)

# the boxs translated outside of image will be filtered along with
# the boxes translated outside of image will be filtered along with
# the corresponding masks, by invoking ``_filter_invalid``.
results[key] = np.concatenate([min_x, min_y, max_x, max_y], axis=-1)

Expand Down
2 changes: 1 addition & 1 deletion ssod/datasets/samplers/semi_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def __iter__(self):
ratio = [0] * len(shuffled_indice_per_dataset)
for u, c in zip(unique, counts):
ratio[u] = c
assert len(ratio) == 2, "Only two set is suppoted"
assert len(ratio) == 2, "Only two set is supported"
if ratio[0] == 0:
ratio[0] = 1
ratio[1] -= 1
Expand Down
2 changes: 1 addition & 1 deletion ssod/utils/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ def patch_config(cfg):
if cfg.get("semi_wrapper", None) is not None:
cfg.model = cfg.semi_wrapper
cfg.pop("semi_wrapper")
# enable enviroment variables
# enable environment variables
setup_env(cfg)
return cfg

0 comments on commit 97d0913

Please sign in to comment.