Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run script from another folder #40

Closed
3dsf opened this issue Aug 15, 2020 · 3 comments
Closed

Can't run script from another folder #40

3dsf opened this issue Aug 15, 2020 · 3 comments

Comments

@3dsf
Copy link

3dsf commented Aug 15, 2020

when running Midas from another folder:

python ../MiDaS/run.py 
initialize
device: cuda
Loading weights:  model-f46da743.pt
Using cache found in /home/3dsf/.cache/torch/hub/facebookresearch_WSL-Images_master
Traceback (most recent call last):
  File "../MiDaS/run.py", line 105, in <module>
    run(INPUT_PATH, OUTPUT_PATH, MODEL_PATH)
  File "../MiDaS/run.py", line 29, in run
    model = MidasNet(model_path, non_negative=True)
  File "/home/3dsf/MiDaS/midas/midas_net.py", line 47, in __init__
    self.load(path)
  File "/home/3dsf/MiDaS/midas/base_model.py", line 11, in load
    parameters = torch.load(path)
  File "/home/3dsf/MiDaS/envs/lib/python3.7/site-packages/torch/serialization.py", line 381, in load
    f = open(f, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'model-f46da743.pt'

This could be a feature, I guess. Anyways, great job, I've tested it several times and here is a magicEye Video made using MiDas

@ranftlr
Copy link
Collaborator

ranftlr commented Aug 17, 2020

We assume that the model weights are in the same folder as the script. Would consider this neither a bug, nor a feature.

Thanks for showing us what you are doing with MiDaS. Very creative application :)

@kjyothiswaroop
Copy link

when running Midas from another folder:

python ../MiDaS/run.py 
initialize
device: cuda
Loading weights:  model-f46da743.pt
Using cache found in /home/3dsf/.cache/torch/hub/facebookresearch_WSL-Images_master
Traceback (most recent call last):
  File "../MiDaS/run.py", line 105, in <module>
    run(INPUT_PATH, OUTPUT_PATH, MODEL_PATH)
  File "../MiDaS/run.py", line 29, in run
    model = MidasNet(model_path, non_negative=True)
  File "/home/3dsf/MiDaS/midas/midas_net.py", line 47, in __init__
    self.load(path)
  File "/home/3dsf/MiDaS/midas/base_model.py", line 11, in load
    parameters = torch.load(path)
  File "/home/3dsf/MiDaS/envs/lib/python3.7/site-packages/torch/serialization.py", line 381, in load
    f = open(f, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'model-f46da743.pt'

This could be a feature, I guess. Anyways, great job, I've tested it several times and here is a magicEye Video made using MiDas

How Did you fix the error I am getting the same error could you help me out?

@3dsf
Copy link
Author

3dsf commented Mar 8, 2021

I think I did something like this

scriptDir = os.path.realpath(__directory__)

if __name__ == "__main__":
    parser = argparse.ArgumentParser()

    parser.add_argument('-i', '--input_path', 
        default=os.path.join(scriptDir,'input'),
        help='folder with input images'
    )

you'd have to do it for all the defaults

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants