dinov2 icon indicating copy to clipboard operation
dinov2 copied to clipboard

Loading Mask2Former with the newest mmcv

Open julkaztwittera opened this issue 1 year ago • 3 comments

Is there any way to load Dinov2 with Mask2Former for instance segmentation having the newest mmcv-full (instead of 1.5.0) installed?

julkaztwittera avatar Oct 10 '23 17:10 julkaztwittera

I found it easier to use the DINOv2 model provided in mmpretrain here. You can load it with something like the following config:

pretrained = 'https://download.openmmlab.com/mmpretrain/v1.0/dinov2/vit-small-p14_dinov2-pre_3rdparty_20230426-5641ca5a.pth'

model = dict(
    type='EncoderDecoder',
    backbone=dict(
        type='mmpretrain.VisionTransformer',
        arch='dinov2-small',
        img_size=518,
        patch_size=14,
        out_indices=(8, 9, 10, 11),
        frozen_stages=-1,
        init_cfg=dict(type='Pretrained', checkpoint=pretrained, prefix='backbone.')
    ),
    decode_head=dict(
        type='Mask2FormerHead',
        in_channels=[384, 384, 384, 384],
        ...
    ),
)

dillonalaird avatar Oct 12 '23 01:10 dillonalaird

I found it easier to use the DINOv2 model provided in mmpretrain here. You can load it with something like the following config:

pretrained = 'https://download.openmmlab.com/mmpretrain/v1.0/dinov2/vit-small-p14_dinov2-pre_3rdparty_20230426-5641ca5a.pth'

model = dict(
    type='EncoderDecoder',
    backbone=dict(
        type='mmpretrain.VisionTransformer',
        arch='dinov2-small',
        img_size=518,
        patch_size=14,
        out_indices=(8, 9, 10, 11),
        frozen_stages=-1,
        init_cfg=dict(type='Pretrained', checkpoint=pretrained, prefix='backbone.')
    ),
    decode_head=dict(
        type='Mask2FormerHead',
        in_channels=[384, 384, 384, 384],
        ...
    ),
)

hi, Could you please provide more specific code and configuration files? Thank you very much 😀

Atumyugi avatar Oct 18 '23 03:10 Atumyugi

does anybody have an example of using dinov2 with nask2former as a head? (without mmcv)

GLASS-z13 avatar Oct 25 '23 22:10 GLASS-z13