Skip to content

Commit 5063ecb

Browse files
committed
update policy
1 parent 8ab11b9 commit 5063ecb

File tree

8 files changed

+49
-38
lines changed

8 files changed

+49
-38
lines changed

library/src/otx/backend/native/models/detection/backbones/dinov3sta.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,13 @@ class DINOv3STAs(nn.Module):
182182
"name": "dinov3_vits16plus",
183183
"weights_path": None,
184184
"interaction_indexes": [5,8,11],
185-
"finetune": True,
186185
"conv_inplane": 64,
187186
"hidden_dim": 256
188187
},
189188
"deimv2_l" : {
190189
"name": "dinov3_vits16",
191190
"weights_path": None,
192191
"interaction_indexes": [5,8,11],
193-
"finetune": True,
194192
"conv_inplane": 32,
195193
"hidden_dim": 224,
196194
},

library/src/otx/backend/native/models/detection/heads/deim_decoder.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ def _get_decoder_input(self,
597597
enc_topk_bbox_unact = torch.concat([denoising_bbox_unact, enc_topk_bbox_unact], dim=1)
598598
content = torch.concat([denoising_logits, content], dim=1)
599599

600-
return content, enc_topk_bbox_unact, enc_topk_bboxes_list, enc_topk_logits_list
600+
return content, enc_topk_bbox_unact, enc_topk_bboxes_list, enc_topk_logits_list, enc_outputs_logits
601601

602602
def _select_topk(self, memory: torch.Tensor, outputs_logits: torch.Tensor, outputs_anchors_unact: torch.Tensor, topk: int):
603603
if self.query_select_method == 'default':
@@ -623,7 +623,11 @@ def _select_topk(self, memory: torch.Tensor, outputs_logits: torch.Tensor, outpu
623623

624624
return topk_memory, topk_logits, topk_anchors
625625

626-
def forward(self, feats, targets=None):
626+
def forward(self,
627+
feats,
628+
targets=None,
629+
explain_mode: bool = False,
630+
):
627631
# input projection and embedding
628632
memory, spatial_shapes = self._get_encoder_input(feats)
629633

@@ -641,7 +645,7 @@ def forward(self, feats, targets=None):
641645
else:
642646
denoising_logits, denoising_bbox_unact, attn_mask, dn_meta = None, None, None, None
643647

644-
init_ref_contents, init_ref_points_unact, enc_topk_bboxes_list, enc_topk_logits_list = \
648+
init_ref_contents, init_ref_points_unact, enc_topk_bboxes_list, enc_topk_logits_list, enc_outputs_logits = \
645649
self._get_decoder_input(memory, spatial_shapes, denoising_logits, denoising_bbox_unact)
646650

647651
# decoder
@@ -660,6 +664,8 @@ def forward(self, feats, targets=None):
660664
attn_mask=attn_mask,
661665
dn_meta=dn_meta)
662666

667+
out_bboxes = out_bboxes.clamp(min=1e-8)
668+
663669
if self.training and dn_meta is not None:
664670
# the output from the first decoder layer, only one
665671
dn_pre_logits, pre_logits = torch.split(pre_logits, dn_meta['dn_num_split'], dim=1)
@@ -690,6 +696,9 @@ def forward(self, feats, targets=None):
690696
out['dn_pre_outputs'] = {'pred_logits': dn_pre_logits, 'pred_boxes': dn_pre_bboxes}
691697
out['dn_meta'] = dn_meta
692698

699+
if explain_mode:
700+
out["raw_logits"] = enc_outputs_logits
701+
693702
return out
694703

695704

library/src/otx/backend/native/models/detection/necks/dfine_hybrid_encoder.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,6 @@ class HybridEncoder:
857857
"deimv2_x": {
858858
"in_channels": [256, 256, 256],
859859
"hidden_dim": 256,
860-
"feat_strides": [8, 16, 32],
861860
"dim_feedforward": 1024,
862861
"expansion": 1.25,
863862
"depth_mult": 1.37

library/src/otx/recipe/detection/deimv2_l.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ callbacks:
5656
data_aug_switch:
5757
class_path: otx.backend.native.callbacks.aug_scheduler.DataAugSwitch
5858
init_args:
59-
policy_epochs: [4, 30, 50]
59+
policy_epochs: [4, 23, 40]
6060
policies:
6161
no_aug:
6262
to_tv_image: false

library/src/otx/recipe/detection/deimv2_s.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ callbacks:
5656
data_aug_switch:
5757
class_path: otx.backend.native.callbacks.aug_scheduler.DataAugSwitch
5858
init_args:
59-
policy_epochs: [4, 23, 40]
59+
policy_epochs: [4, 40, 70]
6060
policies:
6161
no_aug:
6262
to_tv_image: false

library/tests/perf_v2/benchmark.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def train(
127127
dataset_info: DatasetInfo,
128128
sub_work_dir: Path,
129129
seed: int,
130+
num_devices: int = 1,
130131
) -> float:
131132
"""Train model with given dataset and return the total time.
132133
@@ -145,7 +146,7 @@ def train(
145146
dataset_info=dataset_info,
146147
work_dir=sub_work_dir / SubCommand.TRAIN.value,
147148
)
148-
149+
engine.num_devices = num_devices
149150
kwargs = {}
150151
if dataset_info.extra_overrides:
151152
kwargs.update(dataset_info.extra_overrides.get("train", {}))
@@ -329,7 +330,7 @@ def _initialize_engine(
329330
config_path=FOLDER_MAPPINGS[model_info.task] / (model_info.name + ".yaml"),
330331
data_root=self.data_root / dataset_info.path,
331332
work_dir=work_dir,
332-
device=self.accelerator,
333+
device=self.accelerator
333334
)
334335

335336
def run(
@@ -338,6 +339,7 @@ def run(
338339
dataset_info: DatasetInfo,
339340
seed: int,
340341
criteria: list[Criterion],
342+
num_devices: int = 1,
341343
) -> pd.DataFrame | None:
342344
"""Run configured benchmark with given dataset and model and return the result.
343345
@@ -381,6 +383,7 @@ def run(
381383
dataset_info=dataset_info,
382384
sub_work_dir=sub_work_dir,
383385
seed=seed,
386+
num_devices=num_devices
384387
)
385388

386389
self._log_metrics(
@@ -653,6 +656,7 @@ def check(self, result: pd.DataFrame, criteria: list[Criterion]):
653656
dataset_info=dataset_info,
654657
seed=args.seed,
655658
criteria=criteria,
659+
num_devices=args.num_devices,
656660
)
657661
benchmark.check(
658662
result=result,

library/tests/perf_v2/tasks/detection.py

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
# ModelInfo(task=TASK_TYPE.value, name="atss_mobilenetv2", category="default"),
2222
# ModelInfo(task=TASK_TYPE.value, name="yolox_s", category="speed"),
2323
# ModelInfo(task=TASK_TYPE.value, name="dfine_x", category="accuracy"),
24-
ModelInfo(task=TASK_TYPE.value, name="deim_dfine_x", category="accuracy"),
25-
ModelInfo(task=TASK_TYPE.value, name="deim_dfine_l", category="accuracy"),
26-
ModelInfo(task=TASK_TYPE.value, name="deim_dfine_m", category="accuracy"),
27-
ModelInfo(task=TASK_TYPE.value, name="deimv2_x", category="accuracy"),
28-
ModelInfo(task=TASK_TYPE.value, name="deimv2_l", category="accuracy"),
29-
ModelInfo(task=TASK_TYPE.value, name="deimv2_m", category="accuracy"),
24+
# ModelInfo(task=TASK_TYPE.value, name="deim_dfine_x", category="other"),
25+
ModelInfo(task=TASK_TYPE.value, name="deimv2_x", category="other"),
26+
# ModelInfo(task=TASK_TYPE.value, name="deim_dfine_l", category="other"),
27+
ModelInfo(task=TASK_TYPE.value, name="deimv2_l", category="other"),
28+
# ModelInfo(task=TASK_TYPE.value, name="deim_dfine_m", category="other"),
29+
ModelInfo(task=TASK_TYPE.value, name="deimv2_m", category="other"),
30+
ModelInfo(task=TASK_TYPE.value, name="deimv2_s", category="other"),
3031
# ModelInfo(task=TASK_TYPE.value, name="atss_resnext101", category="other"),
3132
# ModelInfo(task=TASK_TYPE.value, name="rtdetr_101", category="other"),
3233
# ModelInfo(task=TASK_TYPE.value, name="rtdetr_18", category="other"),
@@ -41,31 +42,25 @@
4142
DATASET_TEST_CASES = (
4243
[
4344
DatasetInfo(
44-
name=f"pothole_tiny_{idx}",
45-
path=Path("detection/pothole_coco_tiny") / f"{idx}",
45+
name=f"pothole_tiny_2",
46+
path=Path("detection/pothole_coco_tiny/2"),
4647
group="tiny",
47-
)
48-
for idx in (1, 2, 3)
49-
]
50-
+ [
48+
),
5149
DatasetInfo(
52-
name=f"blueberry_tiny_{idx}",
53-
path=Path("detection/blueberry_tiny_coco") / f"{idx}",
50+
name=f"blueberry_small",
51+
path=Path("detection/blue_berry_small"),
5452
group="tiny",
55-
)
56-
for idx in (1, 2, 3)
57-
]
58-
+ [
53+
),
5954
DatasetInfo(
6055
name="wgisd_small",
6156
path=Path("detection/wgisd_merged_coco_small"),
6257
group="small",
6358
),
64-
DatasetInfo(
65-
name="skindetect",
66-
path=Path("detection/skindetect-roboflow"),
67-
group="small",
68-
),
59+
# DatasetInfo(
60+
# name="skindetect",
61+
# path=Path("detection/skindetect-roboflow"),
62+
# group="small",
63+
# ),
6964
DatasetInfo(
7065
name="diopsis",
7166
path=Path("detection/diopsis_coco"),
@@ -76,11 +71,11 @@
7671
path=Path("detection/bdd_medium"),
7772
group="medium",
7873
),
79-
DatasetInfo(
80-
name="Vitens-Aeromonas",
81-
path=Path("detection/Vitens-Aeromonas-coco"),
82-
group="medium",
83-
),
74+
# DatasetInfo(
75+
# name="Vitens-Aeromonas",
76+
# path=Path("detection/Vitens-Aeromonas-coco"),
77+
# group="medium",
78+
# ),
8479
DatasetInfo(
8580
name="visdrone",
8681
path=Path("detection/visdrone_coco_custom_split"),

library/tests/perf_v2/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,4 +352,10 @@ def get_parser() -> ArgumentParser:
352352
default="gpu",
353353
help="Which device to use.",
354354
)
355+
parser.add_argument(
356+
"--num-devices",
357+
type=int,
358+
default=1,
359+
help="How much devices to use during training.",
360+
)
355361
return parser

0 commit comments

Comments
 (0)