Skip to content

Commit 23eefc0

Browse files
Boris PeyriguereBoris Peyriguere
authored andcommitted
Add task-aligned detector specialization pipeline
1 parent 54b591e commit 23eefc0

38 files changed

Lines changed: 2404 additions & 348 deletions

complexity/generative/detection/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
from .config import TRHashDetectorConfig
2222
from .data import (
2323
CocoDetectionDataset,
24+
CocoVideoDetectionDataset,
25+
HuggingFaceDetectionDataset,
2426
SyntheticShapesDataset,
2527
YoloDetectionDataset,
2628
collate_detection,
@@ -55,6 +57,8 @@
5557
"distribution_focal_loss",
5658
"quality_focal_loss",
5759
"CocoDetectionDataset",
60+
"CocoVideoDetectionDataset",
61+
"HuggingFaceDetectionDataset",
5862
"SyntheticShapesDataset",
5963
"YoloDetectionDataset",
6064
"collate_detection",

complexity/generative/detection/config.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ class TRHashDetectorConfig:
6060
quality_loss_weight: float = 1.0
6161
box_l1_weight: float = 0.25
6262
box_iou_weight: float = 1.0
63+
level_adapters_enabled: bool = False
64+
level_adapter_ratio: float = 0.25
65+
class_level_hash_gate_enabled: bool = False
66+
class_level_gate_temperature: float = 1.0
67+
object_weighting_enabled: bool = False
68+
object_weighting_beta: float = 0.999
69+
object_weighting_max: float = 4.0
70+
level_aux_loss_weight: float = 0.0
71+
gate_calibration_loss_weight: float = 0.0
72+
object_contrastive_loss_weight: float = 0.0
73+
object_contrastive_temperature: float = 0.1
74+
object_contrastive_dim: int = 64
75+
video_motion_enabled: bool = False
76+
video_motion_hidden_size: int = 64
77+
video_motion_scale_init: float = 0.1
6378
dropout: float = 0.0
6479
layer_norm_eps: float = 1e-6
6580

@@ -128,6 +143,30 @@ def __post_init__(self) -> None:
128143
raise ValueError("progressive_box_start must be in (0, 1]")
129144
if self.progressive_quality_start < 1.0:
130145
raise ValueError("progressive_quality_start must be at least 1")
146+
if not 0.0 < self.level_adapter_ratio <= 1.0:
147+
raise ValueError("level_adapter_ratio must be in (0, 1]")
148+
if self.class_level_gate_temperature <= 0.0:
149+
raise ValueError("class_level_gate_temperature must be positive")
150+
if not 0.0 <= self.object_weighting_beta < 1.0:
151+
raise ValueError("object_weighting_beta must be in [0, 1)")
152+
if self.object_weighting_max < 1.0:
153+
raise ValueError("object_weighting_max must be at least 1")
154+
if min(
155+
self.level_aux_loss_weight,
156+
self.gate_calibration_loss_weight,
157+
self.object_contrastive_loss_weight,
158+
) < 0.0:
159+
raise ValueError("auxiliary loss weights must be non-negative")
160+
if self.gate_calibration_loss_weight and not self.class_level_hash_gate_enabled:
161+
raise ValueError("gate calibration requires class_level_hash_gate_enabled")
162+
if self.object_contrastive_temperature <= 0.0:
163+
raise ValueError("object_contrastive_temperature must be positive")
164+
if self.object_contrastive_dim <= 0:
165+
raise ValueError("object_contrastive_dim must be positive")
166+
if self.video_motion_hidden_size <= 0:
167+
raise ValueError("video_motion_hidden_size must be positive")
168+
if self.video_motion_scale_init < 0.0:
169+
raise ValueError("video_motion_scale_init must be non-negative")
131170

132171
@property
133172
def grid_size(self) -> int:

0 commit comments

Comments
 (0)