Upload folder using huggingface_hub
Browse files- mmdet_code/mmdetection/mmdet/models/dense_heads/__pycache__/dala_heads.cpython-313.pyc +0 -0
- mmdet_code/mmdetection/mmdet/models/dense_heads/dala_heads.py +29 -7
- mmdet_code/mmdetection/mmdet/models/task_modules/__pycache__/ftsc_calibrator.cpython-313.pyc +0 -0
- mmdet_code/mmdetection/mmdet/models/task_modules/ftsc_calibrator.py +50 -4
- mmdet_code/mmdetection/projects/EfficientDet/configs/__pycache__/efficientdet_effb0_bifpn_dala_ftsc_e0_dwl_control_8xb16-crop512-100e_levir.cpython-313.pyc +0 -0
- mmdet_code/mmdetection/projects/EfficientDet/configs/__pycache__/efficientdet_effb0_bifpn_dala_ftsc_e1_f3_legacy_8xb16-crop512-100e_levir.cpython-313.pyc +0 -0
- mmdet_code/mmdetection/projects/EfficientDet/configs/__pycache__/efficientdet_effb0_bifpn_dala_ftsc_e2_f3_positive_only_8xb16-crop512-100e_levir.cpython-313.pyc +0 -0
- mmdet_code/mmdetection/projects/EfficientDet/configs/__pycache__/efficientdet_effb0_bifpn_dala_ftsc_e3_negative_rebalance_only_8xb16-crop512-100e_levir.cpython-313.pyc +0 -0
- mmdet_code/mmdetection/projects/EfficientDet/configs/__pycache__/efficientdet_effb0_bifpn_dala_ftsc_e4_f3_per_gt_norm_8xb16-crop512-100e_levir.cpython-313.pyc +0 -0
- mmdet_code/mmdetection/projects/EfficientDet/configs/__pycache__/efficientdet_effb0_bifpn_dala_ftsc_e5_position_gaussian_8xb16-crop512-100e_levir.cpython-313.pyc +0 -0
- mmdet_code/mmdetection/projects/EfficientDet/configs/efficientdet_effb0_bifpn_dala_ftsc_e0_dwl_control_8xb16-crop512-100e_levir.py +7 -0
- mmdet_code/mmdetection/projects/EfficientDet/configs/efficientdet_effb0_bifpn_dala_ftsc_e1_f3_legacy_8xb16-crop512-100e_levir.py +13 -0
- mmdet_code/mmdetection/projects/EfficientDet/configs/efficientdet_effb0_bifpn_dala_ftsc_e2_f3_positive_only_8xb16-crop512-100e_levir.py +13 -0
- mmdet_code/mmdetection/projects/EfficientDet/configs/efficientdet_effb0_bifpn_dala_ftsc_e3_negative_rebalance_only_8xb16-crop512-100e_levir.py +14 -0
- mmdet_code/mmdetection/projects/EfficientDet/configs/efficientdet_effb0_bifpn_dala_ftsc_e4_f3_per_gt_norm_8xb16-crop512-100e_levir.py +14 -0
- mmdet_code/mmdetection/projects/EfficientDet/configs/efficientdet_effb0_bifpn_dala_ftsc_e5_position_gaussian_8xb16-crop512-100e_levir.py +20 -0
- mmdet_code/mmdetection/tests/test_models/test_task_modules/test_ftsc_calibrator.py +47 -0
mmdet_code/mmdetection/mmdet/models/dense_heads/__pycache__/dala_heads.cpython-313.pyc
CHANGED
|
Binary files a/mmdet_code/mmdetection/mmdet/models/dense_heads/__pycache__/dala_heads.cpython-313.pyc and b/mmdet_code/mmdetection/mmdet/models/dense_heads/__pycache__/dala_heads.cpython-313.pyc differ
|
|
|
mmdet_code/mmdetection/mmdet/models/dense_heads/dala_heads.py
CHANGED
|
@@ -39,6 +39,10 @@ class DalaAnchorTargetMixin:
|
|
| 39 |
ftsc_weight_min: float = 0.25,
|
| 40 |
ftsc_weight_max: float = 2.0,
|
| 41 |
ftsc_normalize: bool = True,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
ftsc_residual_blend: bool = False,
|
| 43 |
ftsc_warmup_epochs: int = 0,
|
| 44 |
ftsc_ramp_epochs: int = 0,
|
|
@@ -50,15 +54,22 @@ class DalaAnchorTargetMixin:
|
|
| 50 |
**kwargs) -> None:
|
| 51 |
self.use_dwl = use_dwl
|
| 52 |
self.use_ftsc = use_ftsc
|
| 53 |
-
if ftsc_mode not in {
|
|
|
|
|
|
|
|
|
|
| 54 |
raise ValueError(
|
| 55 |
-
'ftsc_mode must be one of level, quality,
|
|
|
|
| 56 |
if ftsc_lambda_level < 0:
|
| 57 |
raise ValueError('ftsc_lambda_level must be non-negative')
|
| 58 |
if ftsc_weight_min <= 0 or ftsc_weight_max <= 0:
|
| 59 |
raise ValueError('FTSC weight clamps must be positive')
|
| 60 |
if ftsc_weight_min > ftsc_weight_max:
|
| 61 |
raise ValueError('ftsc_weight_min must not exceed ftsc_weight_max')
|
|
|
|
|
|
|
|
|
|
| 62 |
self.ftsc_mode = ftsc_mode
|
| 63 |
self.ftsc_lambda_level = ftsc_lambda_level
|
| 64 |
self.ftsc_alpha_level = ftsc_alpha_level
|
|
@@ -66,6 +77,10 @@ class DalaAnchorTargetMixin:
|
|
| 66 |
self.ftsc_weight_min = ftsc_weight_min
|
| 67 |
self.ftsc_weight_max = ftsc_weight_max
|
| 68 |
self.ftsc_normalize = ftsc_normalize
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
self.ftsc_residual_blend = ftsc_residual_blend
|
| 70 |
self.ftsc_warmup_epochs = ftsc_warmup_epochs
|
| 71 |
self.ftsc_ramp_epochs = ftsc_ramp_epochs
|
|
@@ -86,6 +101,8 @@ class DalaAnchorTargetMixin:
|
|
| 86 |
weight_min=ftsc_weight_min,
|
| 87 |
weight_max=ftsc_weight_max,
|
| 88 |
normalize=ftsc_normalize,
|
|
|
|
|
|
|
| 89 |
residual_blend=ftsc_residual_blend,
|
| 90 |
warmup_epochs=ftsc_warmup_epochs,
|
| 91 |
ramp_epochs=ftsc_ramp_epochs,
|
|
@@ -228,11 +245,16 @@ class DalaAnchorTargetMixin:
|
|
| 228 |
ftsc_weights = self._ftsc_positive_weights(
|
| 229 |
anchors, level_ids, gt_bboxes, pos_inds,
|
| 230 |
sampling_result.pos_assigned_gt_inds)
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
|
| 237 |
if unmap_outputs:
|
| 238 |
num_total_anchors = flat_anchors.size(0)
|
|
|
|
| 39 |
ftsc_weight_min: float = 0.25,
|
| 40 |
ftsc_weight_max: float = 2.0,
|
| 41 |
ftsc_normalize: bool = True,
|
| 42 |
+
ftsc_normalize_scope: str = 'image',
|
| 43 |
+
ftsc_gaussian_sigma_scale: float = 0.5,
|
| 44 |
+
ftsc_apply_to_positive: bool = True,
|
| 45 |
+
ftsc_negative_weight_mode: str = 'ftsc_mean',
|
| 46 |
ftsc_residual_blend: bool = False,
|
| 47 |
ftsc_warmup_epochs: int = 0,
|
| 48 |
ftsc_ramp_epochs: int = 0,
|
|
|
|
| 54 |
**kwargs) -> None:
|
| 55 |
self.use_dwl = use_dwl
|
| 56 |
self.use_ftsc = use_ftsc
|
| 57 |
+
if ftsc_mode not in {
|
| 58 |
+
'level', 'quality', 'level_quality', 'position',
|
| 59 |
+
'level_quality_position'
|
| 60 |
+
}:
|
| 61 |
raise ValueError(
|
| 62 |
+
'ftsc_mode must be one of level, quality, level_quality, '
|
| 63 |
+
'position, or level_quality_position')
|
| 64 |
if ftsc_lambda_level < 0:
|
| 65 |
raise ValueError('ftsc_lambda_level must be non-negative')
|
| 66 |
if ftsc_weight_min <= 0 or ftsc_weight_max <= 0:
|
| 67 |
raise ValueError('FTSC weight clamps must be positive')
|
| 68 |
if ftsc_weight_min > ftsc_weight_max:
|
| 69 |
raise ValueError('ftsc_weight_min must not exceed ftsc_weight_max')
|
| 70 |
+
if ftsc_negative_weight_mode not in {'keep', 'ftsc_mean'}:
|
| 71 |
+
raise ValueError(
|
| 72 |
+
'ftsc_negative_weight_mode must be keep or ftsc_mean')
|
| 73 |
self.ftsc_mode = ftsc_mode
|
| 74 |
self.ftsc_lambda_level = ftsc_lambda_level
|
| 75 |
self.ftsc_alpha_level = ftsc_alpha_level
|
|
|
|
| 77 |
self.ftsc_weight_min = ftsc_weight_min
|
| 78 |
self.ftsc_weight_max = ftsc_weight_max
|
| 79 |
self.ftsc_normalize = ftsc_normalize
|
| 80 |
+
self.ftsc_normalize_scope = ftsc_normalize_scope
|
| 81 |
+
self.ftsc_gaussian_sigma_scale = ftsc_gaussian_sigma_scale
|
| 82 |
+
self.ftsc_apply_to_positive = ftsc_apply_to_positive
|
| 83 |
+
self.ftsc_negative_weight_mode = ftsc_negative_weight_mode
|
| 84 |
self.ftsc_residual_blend = ftsc_residual_blend
|
| 85 |
self.ftsc_warmup_epochs = ftsc_warmup_epochs
|
| 86 |
self.ftsc_ramp_epochs = ftsc_ramp_epochs
|
|
|
|
| 101 |
weight_min=ftsc_weight_min,
|
| 102 |
weight_max=ftsc_weight_max,
|
| 103 |
normalize=ftsc_normalize,
|
| 104 |
+
normalize_scope=ftsc_normalize_scope,
|
| 105 |
+
gaussian_sigma_scale=ftsc_gaussian_sigma_scale,
|
| 106 |
residual_blend=ftsc_residual_blend,
|
| 107 |
warmup_epochs=ftsc_warmup_epochs,
|
| 108 |
ramp_epochs=ftsc_ramp_epochs,
|
|
|
|
| 245 |
ftsc_weights = self._ftsc_positive_weights(
|
| 246 |
anchors, level_ids, gt_bboxes, pos_inds,
|
| 247 |
sampling_result.pos_assigned_gt_inds)
|
| 248 |
+
calibrated_pos_label_weights = (
|
| 249 |
+
label_weights[pos_inds] * ftsc_weights)
|
| 250 |
+
if self.ftsc_apply_to_positive:
|
| 251 |
+
label_weights[pos_inds] = calibrated_pos_label_weights
|
| 252 |
+
bbox_weights[pos_inds] = (
|
| 253 |
+
bbox_weights[pos_inds] * ftsc_weights[:, None])
|
| 254 |
+
if (len(neg_inds) > 0 and
|
| 255 |
+
self.ftsc_negative_weight_mode == 'ftsc_mean'):
|
| 256 |
+
label_weights[neg_inds] = calibrated_pos_label_weights.detach(
|
| 257 |
+
).mean()
|
| 258 |
|
| 259 |
if unmap_outputs:
|
| 260 |
num_total_anchors = flat_anchors.size(0)
|
mmdet_code/mmdetection/mmdet/models/task_modules/__pycache__/ftsc_calibrator.cpython-313.pyc
CHANGED
|
Binary files a/mmdet_code/mmdetection/mmdet/models/task_modules/__pycache__/ftsc_calibrator.cpython-313.pyc and b/mmdet_code/mmdetection/mmdet/models/task_modules/__pycache__/ftsc_calibrator.cpython-313.pyc differ
|
|
|
mmdet_code/mmdetection/mmdet/models/task_modules/ftsc_calibrator.py
CHANGED
|
@@ -38,13 +38,18 @@ class FpnTinySupervisionCalibrator(nn.Module):
|
|
| 38 |
"""Compute FTSC weights for positives after hard assignment.
|
| 39 |
|
| 40 |
Args:
|
| 41 |
-
mode: ``level``, ``quality``
|
|
|
|
| 42 |
lambda_level: Decay rate for scale-level octave mismatch.
|
| 43 |
alpha_level: Exponent applied to level compatibility.
|
| 44 |
beta_quality: Exponent applied to relative SimD quality.
|
| 45 |
weight_min: Lower clamp for raw positive weights.
|
| 46 |
weight_max: Upper clamp for raw positive weights.
|
| 47 |
normalize: If true, normalize positive weights to mean one.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
residual_blend: Blend calibrated weights around one instead of applying
|
| 49 |
the full gate immediately.
|
| 50 |
warmup_epochs: Number of initial epochs with zero FTSC strength.
|
|
@@ -67,6 +72,8 @@ class FpnTinySupervisionCalibrator(nn.Module):
|
|
| 67 |
weight_min: float = 0.25,
|
| 68 |
weight_max: float = 2.0,
|
| 69 |
normalize: bool = True,
|
|
|
|
|
|
|
| 70 |
residual_blend: bool = False,
|
| 71 |
warmup_epochs: int = 0,
|
| 72 |
ramp_epochs: int = 0,
|
|
@@ -76,9 +83,13 @@ class FpnTinySupervisionCalibrator(nn.Module):
|
|
| 76 |
strength_init_quality: float = 1.0,
|
| 77 |
strength_reg_weight: float = 0.0) -> None:
|
| 78 |
super().__init__()
|
| 79 |
-
if mode not in {
|
|
|
|
|
|
|
|
|
|
| 80 |
raise ValueError(
|
| 81 |
-
'FTSC mode must be one of level, quality,
|
|
|
|
| 82 |
if lambda_level < 0:
|
| 83 |
raise ValueError('lambda_level must be non-negative')
|
| 84 |
if alpha_level < 0 or beta_quality < 0:
|
|
@@ -87,6 +98,10 @@ class FpnTinySupervisionCalibrator(nn.Module):
|
|
| 87 |
raise ValueError('FTSC weight clamps must be positive')
|
| 88 |
if weight_min > weight_max:
|
| 89 |
raise ValueError('weight_min must not exceed weight_max')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
if warmup_epochs < 0 or ramp_epochs < 0:
|
| 91 |
raise ValueError('FTSC warmup/ramp epochs must be non-negative')
|
| 92 |
if strength_max <= 0:
|
|
@@ -106,6 +121,8 @@ class FpnTinySupervisionCalibrator(nn.Module):
|
|
| 106 |
self.weight_min = weight_min
|
| 107 |
self.weight_max = weight_max
|
| 108 |
self.normalize = normalize
|
|
|
|
|
|
|
| 109 |
self.residual_blend = residual_blend
|
| 110 |
self.warmup_epochs = int(warmup_epochs)
|
| 111 |
self.ramp_epochs = int(ramp_epochs)
|
|
@@ -210,14 +227,34 @@ class FpnTinySupervisionCalibrator(nn.Module):
|
|
| 210 |
weights = weights * relative_quality.pow(
|
| 211 |
self._quality_exponent(relative_quality))
|
| 212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
weights = weights.clamp(self.weight_min, self.weight_max)
|
| 214 |
if self.normalize and weights.numel() > 0:
|
| 215 |
-
weights =
|
| 216 |
if self.residual_blend:
|
| 217 |
strength = self.blend_strength()
|
| 218 |
weights = 1 + strength * (weights - 1)
|
| 219 |
return weights
|
| 220 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
def _level_compatibility(self, anchors: Tensor, level_ids: Tensor,
|
| 222 |
pos_levels: Tensor,
|
| 223 |
pos_gt_bboxes: Tensor) -> Tensor:
|
|
@@ -257,5 +294,14 @@ class FpnTinySupervisionCalibrator(nn.Module):
|
|
| 257 |
gt_quality_mean[pos_assigned_gt_inds].clamp_min(1e-7))
|
| 258 |
return relative_quality.clamp_min(1e-7)
|
| 259 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
|
| 261 |
__all__ = ['FpnTinySupervisionCalibrator', 'simd_quality']
|
|
|
|
| 38 |
"""Compute FTSC weights for positives after hard assignment.
|
| 39 |
|
| 40 |
Args:
|
| 41 |
+
mode: ``level``, ``quality``, ``level_quality``, ``position`` or
|
| 42 |
+
``level_quality_position``.
|
| 43 |
lambda_level: Decay rate for scale-level octave mismatch.
|
| 44 |
alpha_level: Exponent applied to level compatibility.
|
| 45 |
beta_quality: Exponent applied to relative SimD quality.
|
| 46 |
weight_min: Lower clamp for raw positive weights.
|
| 47 |
weight_max: Upper clamp for raw positive weights.
|
| 48 |
normalize: If true, normalize positive weights to mean one.
|
| 49 |
+
normalize_scope: ``image`` normalizes all positives together, while
|
| 50 |
+
``gt`` normalizes positives assigned to the same GT independently.
|
| 51 |
+
gaussian_sigma_scale: Position-Gaussian std as a fraction of GT width
|
| 52 |
+
and height.
|
| 53 |
residual_blend: Blend calibrated weights around one instead of applying
|
| 54 |
the full gate immediately.
|
| 55 |
warmup_epochs: Number of initial epochs with zero FTSC strength.
|
|
|
|
| 72 |
weight_min: float = 0.25,
|
| 73 |
weight_max: float = 2.0,
|
| 74 |
normalize: bool = True,
|
| 75 |
+
normalize_scope: str = 'image',
|
| 76 |
+
gaussian_sigma_scale: float = 0.5,
|
| 77 |
residual_blend: bool = False,
|
| 78 |
warmup_epochs: int = 0,
|
| 79 |
ramp_epochs: int = 0,
|
|
|
|
| 83 |
strength_init_quality: float = 1.0,
|
| 84 |
strength_reg_weight: float = 0.0) -> None:
|
| 85 |
super().__init__()
|
| 86 |
+
if mode not in {
|
| 87 |
+
'level', 'quality', 'level_quality', 'position',
|
| 88 |
+
'level_quality_position'
|
| 89 |
+
}:
|
| 90 |
raise ValueError(
|
| 91 |
+
'FTSC mode must be one of level, quality, level_quality, '
|
| 92 |
+
'position, or level_quality_position')
|
| 93 |
if lambda_level < 0:
|
| 94 |
raise ValueError('lambda_level must be non-negative')
|
| 95 |
if alpha_level < 0 or beta_quality < 0:
|
|
|
|
| 98 |
raise ValueError('FTSC weight clamps must be positive')
|
| 99 |
if weight_min > weight_max:
|
| 100 |
raise ValueError('weight_min must not exceed weight_max')
|
| 101 |
+
if normalize_scope not in {'image', 'gt'}:
|
| 102 |
+
raise ValueError('normalize_scope must be image or gt')
|
| 103 |
+
if gaussian_sigma_scale <= 0:
|
| 104 |
+
raise ValueError('gaussian_sigma_scale must be positive')
|
| 105 |
if warmup_epochs < 0 or ramp_epochs < 0:
|
| 106 |
raise ValueError('FTSC warmup/ramp epochs must be non-negative')
|
| 107 |
if strength_max <= 0:
|
|
|
|
| 121 |
self.weight_min = weight_min
|
| 122 |
self.weight_max = weight_max
|
| 123 |
self.normalize = normalize
|
| 124 |
+
self.normalize_scope = normalize_scope
|
| 125 |
+
self.gaussian_sigma_scale = gaussian_sigma_scale
|
| 126 |
self.residual_blend = residual_blend
|
| 127 |
self.warmup_epochs = int(warmup_epochs)
|
| 128 |
self.ramp_epochs = int(ramp_epochs)
|
|
|
|
| 227 |
weights = weights * relative_quality.pow(
|
| 228 |
self._quality_exponent(relative_quality))
|
| 229 |
|
| 230 |
+
if 'position' in self.mode:
|
| 231 |
+
with torch.no_grad():
|
| 232 |
+
position_quality = self._position_gaussian_quality(
|
| 233 |
+
pos_anchors, pos_gt_bboxes)
|
| 234 |
+
weights = weights * position_quality
|
| 235 |
+
|
| 236 |
weights = weights.clamp(self.weight_min, self.weight_max)
|
| 237 |
if self.normalize and weights.numel() > 0:
|
| 238 |
+
weights = self._normalize_weights(weights, pos_assigned_gt_inds)
|
| 239 |
if self.residual_blend:
|
| 240 |
strength = self.blend_strength()
|
| 241 |
weights = 1 + strength * (weights - 1)
|
| 242 |
return weights
|
| 243 |
|
| 244 |
+
def _normalize_weights(self, weights: Tensor,
|
| 245 |
+
pos_assigned_gt_inds: Tensor) -> Tensor:
|
| 246 |
+
if self.normalize_scope == 'image':
|
| 247 |
+
return weights / weights.mean().clamp_min(1e-7)
|
| 248 |
+
|
| 249 |
+
gt_weight_sum = weights.new_zeros(
|
| 250 |
+
(int(pos_assigned_gt_inds.max().item()) + 1, ))
|
| 251 |
+
gt_weight_count = weights.new_zeros(gt_weight_sum.shape)
|
| 252 |
+
gt_weight_sum.scatter_add_(0, pos_assigned_gt_inds, weights)
|
| 253 |
+
gt_weight_count.scatter_add_(
|
| 254 |
+
0, pos_assigned_gt_inds, torch.ones_like(weights))
|
| 255 |
+
gt_weight_mean = gt_weight_sum / gt_weight_count.clamp_min(1)
|
| 256 |
+
return weights / gt_weight_mean[pos_assigned_gt_inds].clamp_min(1e-7)
|
| 257 |
+
|
| 258 |
def _level_compatibility(self, anchors: Tensor, level_ids: Tensor,
|
| 259 |
pos_levels: Tensor,
|
| 260 |
pos_gt_bboxes: Tensor) -> Tensor:
|
|
|
|
| 294 |
gt_quality_mean[pos_assigned_gt_inds].clamp_min(1e-7))
|
| 295 |
return relative_quality.clamp_min(1e-7)
|
| 296 |
|
| 297 |
+
def _position_gaussian_quality(self, pos_anchors: Tensor,
|
| 298 |
+
pos_gt_bboxes: Tensor) -> Tensor:
|
| 299 |
+
anchor_ctr = (pos_anchors[:, :2] + pos_anchors[:, 2:]) * 0.5
|
| 300 |
+
gt_ctr = (pos_gt_bboxes[:, :2] + pos_gt_bboxes[:, 2:]) * 0.5
|
| 301 |
+
gt_wh = (pos_gt_bboxes[:, 2:] - pos_gt_bboxes[:, :2]).clamp_min(1e-7)
|
| 302 |
+
sigma = gt_wh * self.gaussian_sigma_scale
|
| 303 |
+
normalized_offset = ((anchor_ctr - gt_ctr) / sigma).square().sum(dim=-1)
|
| 304 |
+
return torch.exp(-0.5 * normalized_offset).clamp_min(1e-7)
|
| 305 |
+
|
| 306 |
|
| 307 |
__all__ = ['FpnTinySupervisionCalibrator', 'simd_quality']
|
mmdet_code/mmdetection/projects/EfficientDet/configs/__pycache__/efficientdet_effb0_bifpn_dala_ftsc_e0_dwl_control_8xb16-crop512-100e_levir.cpython-313.pyc
ADDED
|
Binary file (506 Bytes). View file
|
|
|
mmdet_code/mmdetection/projects/EfficientDet/configs/__pycache__/efficientdet_effb0_bifpn_dala_ftsc_e1_f3_legacy_8xb16-crop512-100e_levir.cpython-313.pyc
ADDED
|
Binary file (710 Bytes). View file
|
|
|
mmdet_code/mmdetection/projects/EfficientDet/configs/__pycache__/efficientdet_effb0_bifpn_dala_ftsc_e2_f3_positive_only_8xb16-crop512-100e_levir.cpython-313.pyc
ADDED
|
Binary file (715 Bytes). View file
|
|
|
mmdet_code/mmdetection/projects/EfficientDet/configs/__pycache__/efficientdet_effb0_bifpn_dala_ftsc_e3_negative_rebalance_only_8xb16-crop512-100e_levir.cpython-313.pyc
ADDED
|
Binary file (784 Bytes). View file
|
|
|
mmdet_code/mmdetection/projects/EfficientDet/configs/__pycache__/efficientdet_effb0_bifpn_dala_ftsc_e4_f3_per_gt_norm_8xb16-crop512-100e_levir.cpython-313.pyc
ADDED
|
Binary file (741 Bytes). View file
|
|
|
mmdet_code/mmdetection/projects/EfficientDet/configs/__pycache__/efficientdet_effb0_bifpn_dala_ftsc_e5_position_gaussian_8xb16-crop512-100e_levir.cpython-313.pyc
ADDED
|
Binary file (933 Bytes). View file
|
|
|
mmdet_code/mmdetection/projects/EfficientDet/configs/efficientdet_effb0_bifpn_dala_ftsc_e0_dwl_control_8xb16-crop512-100e_levir.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""EfficientDet-D0 DALA E0: matched DWL control.
|
| 2 |
+
|
| 3 |
+
E0 keeps DALA assignment and DWL weighting unchanged. It is the matched control
|
| 4 |
+
for the E-series FTSC mechanism ablations.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
_base_ = './efficientdet_effb0_bifpn_dala_s0_control_8xb16-crop512-100e_levir.py'
|
mmdet_code/mmdetection/projects/EfficientDet/configs/efficientdet_effb0_bifpn_dala_ftsc_e1_f3_legacy_8xb16-crop512-100e_levir.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""EfficientDet-D0 DALA E1: reproduce legacy FTSC-F3 exactly.
|
| 2 |
+
|
| 3 |
+
Positive cls/box weights are DWL x F3, and negative cls weights are reset to
|
| 4 |
+
mean(DWL x F3), matching the original F3 implementation.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
_base_ = './efficientdet_effb0_bifpn_dala_ftsc_f3_level_quality_8xb16-crop512-100e_levir.py'
|
| 8 |
+
|
| 9 |
+
model = dict(
|
| 10 |
+
bbox_head=dict(
|
| 11 |
+
ftsc_apply_to_positive=True,
|
| 12 |
+
ftsc_negative_weight_mode='ftsc_mean',
|
| 13 |
+
ftsc_normalize_scope='image'))
|
mmdet_code/mmdetection/projects/EfficientDet/configs/efficientdet_effb0_bifpn_dala_ftsc_e2_f3_positive_only_8xb16-crop512-100e_levir.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""EfficientDet-D0 DALA E2: positive-only FTSC-F3.
|
| 2 |
+
|
| 3 |
+
Positive cls/box weights are DWL x F3. Negative cls weights keep the DWL
|
| 4 |
+
baseline value, so this removes the negative-rebalancing confound from E1.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
_base_ = './efficientdet_effb0_bifpn_dala_ftsc_f3_level_quality_8xb16-crop512-100e_levir.py'
|
| 8 |
+
|
| 9 |
+
model = dict(
|
| 10 |
+
bbox_head=dict(
|
| 11 |
+
ftsc_apply_to_positive=True,
|
| 12 |
+
ftsc_negative_weight_mode='keep',
|
| 13 |
+
ftsc_normalize_scope='image'))
|
mmdet_code/mmdetection/projects/EfficientDet/configs/efficientdet_effb0_bifpn_dala_ftsc_e3_negative_rebalance_only_8xb16-crop512-100e_levir.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""EfficientDet-D0 DALA E3: FTSC negative rebalancing only.
|
| 2 |
+
|
| 3 |
+
Positive cls/box weights stay at DWL. Negative cls weights are reset to
|
| 4 |
+
mean(DWL x detached F3), measuring whether E1's effect comes from background
|
| 5 |
+
loss scaling rather than positive supervision.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
_base_ = './efficientdet_effb0_bifpn_dala_ftsc_f3_level_quality_8xb16-crop512-100e_levir.py'
|
| 9 |
+
|
| 10 |
+
model = dict(
|
| 11 |
+
bbox_head=dict(
|
| 12 |
+
ftsc_apply_to_positive=False,
|
| 13 |
+
ftsc_negative_weight_mode='ftsc_mean',
|
| 14 |
+
ftsc_normalize_scope='image'))
|
mmdet_code/mmdetection/projects/EfficientDet/configs/efficientdet_effb0_bifpn_dala_ftsc_e4_f3_per_gt_norm_8xb16-crop512-100e_levir.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""EfficientDet-D0 DALA E4: FTSC-F3 with per-GT normalization.
|
| 2 |
+
|
| 3 |
+
Positive weights are DWL x F3, but FTSC weights are normalized independently
|
| 4 |
+
inside each GT's assigned-positive set. Negative cls weights keep the DWL
|
| 5 |
+
baseline value.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
_base_ = './efficientdet_effb0_bifpn_dala_ftsc_f3_level_quality_8xb16-crop512-100e_levir.py'
|
| 9 |
+
|
| 10 |
+
model = dict(
|
| 11 |
+
bbox_head=dict(
|
| 12 |
+
ftsc_apply_to_positive=True,
|
| 13 |
+
ftsc_negative_weight_mode='keep',
|
| 14 |
+
ftsc_normalize_scope='gt'))
|
mmdet_code/mmdetection/projects/EfficientDet/configs/efficientdet_effb0_bifpn_dala_ftsc_e5_position_gaussian_8xb16-crop512-100e_levir.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""EfficientDet-D0 DALA E5: Position-Gaussian positive evidence.
|
| 2 |
+
|
| 3 |
+
Positive cls/box weights are DWL x a GT-centered Gaussian prior over anchor
|
| 4 |
+
centres. Negative cls weights keep the DWL baseline value. This tests evidence
|
| 5 |
+
that does not reuse SimD/DALA ranking.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
_base_ = './efficientdet_effb0_bifpn_dala_s0_control_8xb16-crop512-100e_levir.py'
|
| 9 |
+
|
| 10 |
+
model = dict(
|
| 11 |
+
bbox_head=dict(
|
| 12 |
+
use_ftsc=True,
|
| 13 |
+
ftsc_mode='position',
|
| 14 |
+
ftsc_gaussian_sigma_scale=0.5,
|
| 15 |
+
ftsc_weight_min=0.25,
|
| 16 |
+
ftsc_weight_max=2.0,
|
| 17 |
+
ftsc_normalize=True,
|
| 18 |
+
ftsc_normalize_scope='image',
|
| 19 |
+
ftsc_apply_to_positive=True,
|
| 20 |
+
ftsc_negative_weight_mode='keep'))
|
mmdet_code/mmdetection/tests/test_models/test_task_modules/test_ftsc_calibrator.py
CHANGED
|
@@ -66,6 +66,53 @@ def test_ftsc_normalizes_positive_weights_to_mean_one():
|
|
| 66 |
assert torch.allclose(weights.mean(), torch.ones(()), atol=1e-6)
|
| 67 |
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
def test_ftsc_no_positive_returns_empty_weight_vector():
|
| 70 |
calibrator = FpnTinySupervisionCalibrator()
|
| 71 |
weights = calibrator(
|
|
|
|
| 66 |
assert torch.allclose(weights.mean(), torch.ones(()), atol=1e-6)
|
| 67 |
|
| 68 |
|
| 69 |
+
def test_ftsc_normalizes_positive_weights_per_gt():
|
| 70 |
+
calibrator = FpnTinySupervisionCalibrator(
|
| 71 |
+
mode='quality', normalize=True, normalize_scope='gt')
|
| 72 |
+
anchors = torch.tensor([
|
| 73 |
+
[0., 0., 10., 10.],
|
| 74 |
+
[2., 2., 12., 12.],
|
| 75 |
+
[20., 20., 40., 40.],
|
| 76 |
+
[22., 22., 42., 42.],
|
| 77 |
+
])
|
| 78 |
+
level_ids = torch.tensor([0, 0, 1, 1])
|
| 79 |
+
gt_bboxes = torch.tensor([
|
| 80 |
+
[0., 0., 10., 10.],
|
| 81 |
+
[20., 20., 40., 40.],
|
| 82 |
+
])
|
| 83 |
+
assigned = torch.tensor([0, 0, 1, 1])
|
| 84 |
+
|
| 85 |
+
weights = calibrator(
|
| 86 |
+
anchors,
|
| 87 |
+
level_ids,
|
| 88 |
+
gt_bboxes,
|
| 89 |
+
pos_inds=torch.tensor([0, 1, 2, 3]),
|
| 90 |
+
pos_assigned_gt_inds=assigned)
|
| 91 |
+
|
| 92 |
+
assert torch.allclose(weights[assigned == 0].mean(), torch.ones(()))
|
| 93 |
+
assert torch.allclose(weights[assigned == 1].mean(), torch.ones(()))
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def test_ftsc_position_gaussian_prefers_gt_center():
|
| 97 |
+
calibrator = FpnTinySupervisionCalibrator(
|
| 98 |
+
mode='position', normalize=False)
|
| 99 |
+
anchors = torch.tensor([
|
| 100 |
+
[0., 0., 10., 10.],
|
| 101 |
+
[4., 4., 14., 14.],
|
| 102 |
+
])
|
| 103 |
+
level_ids = torch.tensor([0, 0])
|
| 104 |
+
gt_bboxes = torch.tensor([[0., 0., 10., 10.]])
|
| 105 |
+
|
| 106 |
+
weights = calibrator(
|
| 107 |
+
anchors,
|
| 108 |
+
level_ids,
|
| 109 |
+
gt_bboxes,
|
| 110 |
+
pos_inds=torch.tensor([0, 1]),
|
| 111 |
+
pos_assigned_gt_inds=torch.tensor([0, 0]))
|
| 112 |
+
|
| 113 |
+
assert weights[0] > weights[1]
|
| 114 |
+
|
| 115 |
+
|
| 116 |
def test_ftsc_no_positive_returns_empty_weight_vector():
|
| 117 |
calibrator = FpnTinySupervisionCalibrator()
|
| 118 |
weights = calibrator(
|