![]() In any case, if your Python script file and your data input file are not in the same directory, you always have to specify either a relative path between them or you have to use an absolute path for one of them.To find the current directory of a file in Python, you can use the os.path.dirname() function from the os.path module. In order to make this work, the directory containing the python executable must be in the PATH, a so-called environment variable that contains directories that are automatically used for searching executables when you enter a command. The current working directory usually is the directory in which you started the program. If the user does not pass the full path to the file (on Unix type systems this means a path that starts with a slash), the python file path is interpreted relatively to the current working directory. In the above code, all of the information needed to locate the file is contained in the path string - absolute path. So, try using the exact, or absolute path.įile = open(r'C:\path\to\your\filename.ext') //absolute path The error “ FileNotFoundError: No such file or directory” is telling you that there is no file of that name in the working directory. In the above code, you are not giving the full path to a file to the open() function, just its name - a relative path. This is called a relative path.įile = open('filename.ext') //relative path When you open a file with the name “filename.ext” you are telling the open() function that your file is in the current working directory. Stack Overflow | The World’s Largest Online Community for DevelopersįileNotFoundError: No such file or directory: Can you provide the smallest possible example that fails? Stack Overflow How to create a Minimal, Reproducible Example - Help Center Maybe you are trying to use the wrong data file. You need to do thisĭebugging yourself – I don’t have access to your code or data files or Using, and make sure it is the correct file. It looks like you are using the “torch” third-party library, and it is That will tell us what file is being used. Immediately before line 180, saying: print(graphonomy_model_path) Line 180 says: state_dict = torch.load(graphonomy_model_path)īut we don’t know what the graphonomy_model_path is. One thing which would be very useful: in this script: /content/LOHO/loho.py Where did this file come from? Did you create it? Now you are unpicklingĪ model from a “.pth” file: Loading model from: /content/LOHO/networks/lpips/weights/v0.1/vgg.pth Earlier, your file wasĪ PNG image: 00018.png, if I remember correctly. This does not seem to be the same file as before. You know it is a good file? Where did you get it from? It says: RuntimeError: unexpected EOF, expected 1362420 more bytes. The error message looks fairly complete and self-explanatory to “How do I find out the path to my file?” is a good question to ask, if Until it worked? Please, if you are having problems with specific tasks, You “somehow” got the path right? What did you do, try random paths RuntimeError: unexpected EOF, expected 1362420 more bytes. Return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)įile “/usr/local/lib/python3.7/site-packages/torch/serialization.py”, line 779, in _legacy_loadĭeserialized_objects._set_from_file(f, offset, f_should_read_directly) ![]() ![]() State_dict = torch.load(graphonomy_model_path)įile “/usr/local/lib/python3.7/site-packages/torch/serialization.py”, line 593, in load ![]() Loading model from: /content/LOHO/networks/lpips/weights/v0.1/vgg.pthįile “/content/LOHO/loho.py”, line 180, in But now I am getting this "Runtime Error"
0 Comments
Leave a Reply. |