isl-org / DPT

Dense Prediction Transformers
MIT License
1.96k stars 254 forks source link

Could you share the weights of encoder pretrained on imagenet? #43

Closed EricKani closed 3 years ago

EricKani commented 3 years ago

Could you share the weights of encoder pretrained on imagenet? Thanks~

ranftlr commented 3 years ago

These weights are part of timm. If you only want the backbone:

import timm
model = timm.create_model("vit_large_patch16_384"", pretrained=True)

See https://github.com/rwightman/pytorch-image-models/blob/master/timm/models/vision_transformer.py for a list of models.

If you want to initialize DPT with ImageNet weights in the encoder and random initialization in the decoder:

1) Set this line to True: https://github.com/isl-org/DPT/blob/f43ef9e08d70a752195028a51be5e1aff227b913/dpt/models.py#L52

2) Instantiate a DPT model with path=None. Example:

model = DPTDepthModel(
            path=None,
            backbone="vitl16_384",
            non_negative=True,
            enable_attention_hooks=False)
EricKani commented 3 years ago

Got it! Thanks a lot for your detailed reply! Best