apple / ml-depth-pro

Depth Pro: Sharp Monocular Metric Depth in Less Than a Second.
Other
3.66k stars 244 forks source link

name 'DepthPro' is not defined #29

Open wanghuahua576 opened 1 month ago

wanghuahua576 commented 1 month ago

when I was using run.py in command:

(depth-pro) G:\ml-depth-pro-main\src\depth_pro\cli> python run.py -i data/example.jpg

the command line shows:

File "G:\ml-depth-pro-main\src\depth_pro\depth_pro.py", line 86, in ) -> Tuple[DepthPro, Compose]: NameError: name 'DepthPro' is not defined

it seems cannot find the model, how can i solve this problem? thx

wanghuahua576 commented 1 month ago

put the "class DepthPro" before the line154: def create_model_and_transforms

ManishKumarYadavalli commented 1 month ago

put the "class DepthPro" before the line154: def create_model_and_transforms

iheanu commented 1 month ago

Maybe the import package path is wrong, try this from ...depth_pro import create_model_and_transforms, load_rgb

99991 commented 1 month ago

Maybe you are using an old Python version which does not support type declarations after type annotations. There are three solutions:

  1. put the class DepthPro before the type annotation as you already mentioned
  2. put quotes around DepthPro like so: ) -> Tuple["DepthPro", Compose]:
  3. (for Python 3.7+) add from __future__ import annotations at the top of the Python file
wanghuahua576 commented 1 month ago

Maybe you are using an old Python version which does not support type declarations after type annotations. There are three solutions:

  1. put the class DepthPro before the type annotation as you already mentioned
  2. put quotes around DepthPro like so: ) -> Tuple["DepthPro", Compose]:
  3. (for Python 3.7+) add from __future__ import annotations at the top of the Python file

I tried the methods above, and it works. By the way, the statement of solution3 is in the code, i forgot ,thxxxxx~