Skip to content

Commit 5d8812b

Browse files
author
Burak Mandira
committed
ADD soft teacher code
1 parent 186e3df commit 5d8812b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+5446
-1
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 utkutpcgl
3+
Copyright (c) 2021 Microsoft
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pre:
2+
python -m pip install -r requirements.txt -f https://download.pytorch.org/whl/torch_stable.html
3+
mkdir -p thirdparty
4+
git clone https://github.com/open-mmlab/mmdetection.git thirdparty/mmdetection
5+
cd thirdparty/mmdetection && python -m pip install -e .
6+
install:
7+
make pre
8+
python -m pip install -e .
9+
clean:
10+
rm -rf thirdparty
11+
rm -r ssod.egg-info

configs/baseline/base.py

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
mmdet_base = "../../thirdparty/mmdetection/configs/_base_"
2+
_base_ = [
3+
f"{mmdet_base}/models/faster_rcnn_r50_fpn.py",
4+
f"{mmdet_base}/datasets/coco_detection.py",
5+
f"{mmdet_base}/schedules/schedule_1x.py",
6+
f"{mmdet_base}/default_runtime.py",
7+
]
8+
9+
model = dict(
10+
backbone=dict(
11+
norm_cfg=dict(requires_grad=False),
12+
norm_eval=True,
13+
style="caffe",
14+
init_cfg=dict(
15+
type="Pretrained", checkpoint="open-mmlab://detectron2/resnet50_caffe"
16+
),
17+
)
18+
)
19+
20+
img_norm_cfg = dict(mean=[103.530, 116.280, 123.675], std=[1.0, 1.0, 1.0], to_rgb=False)
21+
22+
train_pipeline = [
23+
dict(type="LoadImageFromFile"),
24+
dict(type="LoadAnnotations", with_bbox=True),
25+
dict(
26+
type="Sequential",
27+
transforms=[
28+
dict(
29+
type="RandResize",
30+
img_scale=[(1333, 400), (1333, 1200)],
31+
multiscale_mode="range",
32+
keep_ratio=True,
33+
),
34+
dict(type="RandFlip", flip_ratio=0.5),
35+
dict(
36+
type="OneOf",
37+
transforms=[
38+
dict(type=k)
39+
for k in [
40+
"Identity",
41+
"AutoContrast",
42+
"RandEqualize",
43+
"RandSolarize",
44+
"RandColor",
45+
"RandContrast",
46+
"RandBrightness",
47+
"RandSharpness",
48+
"RandPosterize",
49+
]
50+
],
51+
),
52+
],
53+
),
54+
dict(type="Pad", size_divisor=32),
55+
dict(type="Normalize", **img_norm_cfg),
56+
dict(type="ExtraAttrs", tag="sup"),
57+
dict(type="DefaultFormatBundle"),
58+
dict(
59+
type="Collect",
60+
keys=["img", "gt_bboxes", "gt_labels"],
61+
meta_keys=(
62+
"filename",
63+
"ori_shape",
64+
"img_shape",
65+
"img_norm_cfg",
66+
"pad_shape",
67+
"scale_factor",
68+
"tag",
69+
),
70+
),
71+
]
72+
73+
test_pipeline = [
74+
dict(type="LoadImageFromFile"),
75+
dict(
76+
type="MultiScaleFlipAug",
77+
img_scale=(1333, 800),
78+
flip=False,
79+
transforms=[
80+
dict(type="Resize", keep_ratio=True),
81+
dict(type="RandomFlip"),
82+
dict(type="Normalize", **img_norm_cfg),
83+
dict(type="Pad", size_divisor=32),
84+
dict(type="ImageToTensor", keys=["img"]),
85+
dict(type="Collect", keys=["img"]),
86+
],
87+
),
88+
]
89+
90+
data = dict(
91+
samples_per_gpu=1,
92+
workers_per_gpu=1,
93+
train=dict(pipeline=train_pipeline),
94+
val=dict(pipeline=test_pipeline),
95+
test=dict(pipeline=test_pipeline),
96+
)
97+
98+
optimizer = dict(type="SGD", lr=0.01, momentum=0.9, weight_decay=0.0001)
99+
lr_config = dict(step=[120000, 160000])
100+
runner = dict(_delete_=True, type="IterBasedRunner", max_iters=180000)
101+
checkpoint_config = dict(by_epoch=False, interval=4000, max_keep_ckpts=10)
102+
evaluation = dict(interval=4000)
103+
104+
fp16 = dict(loss_scale="dynamic")
105+
106+
log_config = dict(
107+
interval=50,
108+
hooks=[
109+
dict(type="TextLoggerHook", by_epoch=False),
110+
dict(
111+
type="WandbLoggerHook",
112+
init_kwargs=dict(
113+
project="pre_release",
114+
name="${cfg_name}",
115+
config=dict(
116+
work_dirs="${work_dir}",
117+
total_step="${runner.max_iters}",
118+
),
119+
),
120+
by_epoch=False,
121+
),
122+
],
123+
)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
_base_ = "base.py"
2+
model = dict(
3+
backbone=dict(
4+
depth=101,
5+
init_cfg=dict(checkpoint="open-mmlab://detectron2/resnet101_caffe"),
6+
)
7+
)
8+
9+
data = dict(
10+
samples_per_gpu=2,
11+
workers_per_gpu=2,
12+
train=dict(
13+
ann_file="data/coco/annotations/instances_train2017.json",
14+
img_prefix="data/coco/train2017/",
15+
),
16+
)
17+
18+
optimizer = dict(lr=0.02)
19+
lr_config = dict(step=[120000 * 4, 160000 * 4])
20+
runner = dict(_delete_=True, type="IterBasedRunner", max_iters=180000 * 4)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
_base_ = "base.py"
2+
3+
data = dict(
4+
samples_per_gpu=2,
5+
workers_per_gpu=2,
6+
train=dict(
7+
ann_file="data/coco/annotations/instances_train2017.json",
8+
img_prefix="data/coco/train2017/",
9+
),
10+
)
11+
12+
optimizer = dict(lr=0.02)
13+
lr_config = dict(step=[120000 * 4, 160000 * 4])
14+
runner = dict(_delete_=True, type="IterBasedRunner", max_iters=180000 * 4)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
_base_ = "base.py"
2+
fold = 1
3+
percent = 1
4+
data = dict(
5+
samples_per_gpu=1,
6+
workers_per_gpu=1,
7+
train=dict(
8+
ann_file="data/coco/annotations/semi_supervised/instances_train2017.${fold}@${percent}.json",
9+
img_prefix="data/coco/train2017/",
10+
),
11+
)
12+
work_dir = "work_dirs/${cfg_name}/${percent}/${fold}"
13+
log_config = dict(
14+
interval=50,
15+
hooks=[
16+
dict(type="TextLoggerHook"),
17+
dict(
18+
type="WandbLoggerHook",
19+
init_kwargs=dict(
20+
project="pre_release",
21+
name="${cfg_name}",
22+
config=dict(
23+
fold="${fold}",
24+
percent="${percent}",
25+
work_dirs="${work_dir}",
26+
total_step="${runner.max_iters}",
27+
),
28+
),
29+
by_epoch=False,
30+
),
31+
],
32+
)

0 commit comments

Comments
 (0)