lpiccinelli-eth / UniDepth

Universal Monocular Metric Depth Estimation
Other
462 stars 39 forks source link

TypeError: UniDepthV1.__init__() missing 1 required positional argument: 'config' #35

Open mrwangxinqwe opened 2 months ago

mrwangxinqwe commented 2 months ago

My version was cloned on April 26 and has the same problems that people have asked about before.That's the question that comes up: Torch version: 2.2.0+cu118 Traceback (most recent call last): File "/home/wx/Downloads/UniDepth-main/scripts/demo.py", line 40, in model = UniDepthV1.from_pretrained("lpiccinelli/unidepth-v1-vitl14") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/wx/anaconda3/envs/unidepth/lib/python3.11/site-packages/huggingface_hub/utils/_validators.py", line 119, in _inner_fn return fn(*args, kwargs) ^^^^^^^^^^^^^^^^^^^ File "/home/wx/anaconda3/envs/unidepth/lib/python3.11/site-packages/huggingface_hub/hub_mixin.py", line 420, in from_pretrained instance = cls._from_pretrained( ^^^^^^^^^^^^^^^^^^^^^ File "/home/wx/anaconda3/envs/unidepth/lib/python3.11/site-packages/huggingface_hub/hub_mixin.py", line 643, in _from_pretrained model = cls(model_kwargs) ^^^^^^^^^^^^^^^^^^^ TypeError: UniDepthV1.init() missing 1 required positional argument: 'config'

mrwangxinqwe commented 2 months ago

I replaced 'model = UniDepthV1.from_pretrained("lpiccinelli/unidepth-v1-vitl14")' with 'model = torch.hub.load( "lpiccinelli-eth/unidepth", "UniDepthV1_ConvNextL", # MAP_BACKBONES = {"ViTL14": "vitl14", "ConvNextL": "cnvnxtl"} pretrained=True, trust_repo=True, force_reload=True, )' in demo.py , demo.py has the desired effect.

lpiccinelli-eth commented 2 months ago

Whichhuggingface_hub version are you using?

mrwangxinqwe commented 2 months ago

@lpiccinelli-eth huggingface-hub 0.22.2

mrwangxinqwe commented 2 months ago

I lowered the version to 0.22.0, but still got the same error.

carzy-z commented 6 days ago

I also have this problem, can you tell me how to solve it?

lpiccinelli-eth commented 6 days ago

It looks like from_pretrained method of ModelHubMixin class fails at downloading the configs from Huggingface repo, so the method cannot populate the model arguments like the config. You can try setting the parameter force_download in UniDepthV2.from_pretrained(..., force_download=True), the plan B would be using Torch Hub.