Skip to content

[FEAT] DEIMv2 implementation #756

Description

@tetelias

💡 Is your feature request related to a problem?

I would like to integrate DEIMv2 into lightly-train. DEIMv2 has 2 families of models,
DINOv3 and HGNetv2/LiteEncoder, but I would suggest only DINOv3-based for now.

🧰 Describe the solution you'd like

A lot of code is already in place, though some will need divergence resolution.
DEIMCriterion(looks close, but differs from DFINECriterion with mal_alpha=None,
use_uni_set=True and loss loss_mal added) and DEIMTransformer will need to be added.

🛠 Alternatives you've considered

Not sure, if applicable

📝 Additional context

Some of code with divergence:

  • when class LQE creates MLP, lightly just uses default "relu", while DEIM allows to create MLP with a different one.
  • box_cxcywh_to_xyxy function in DEIM adds clamp(min=0.0) to width and height
  • layer name converter will be required when loading checkpoints
  • HybridEncoder:
    • fusion of upsample_feat+feat_low and downsample_feat+feat_height in DEIMv2 can be via both sum and concatenation,
      while Lighly always go for concatenation. And DEIMv2 pretrained models with sum
    • DEIMv2 has larger encoder block variety covering RT-DETR, D-FINE and DEIM aggregation path.
    • DEIMv2 uses 1x1 conv + depthwise spatial stride-2 conv for downsampling in both D-FINE and DEIM
    • DEIMv2 does not always uses input projection and goes for nn.Identity when in_channels is equal to hidden_dim, which is the case for DINOv3
  • DEIMv2 has additional parameters and imports in HungarianMatcher to accomodate late stage training, where it switches to class-score × IoU ranking objective.
  • DEIMCriterion can inherit from DFINECriterion to add parameters and loss.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions