tfaehse / DashcamCleaner

Censor identifiable information in videos, in particular dashcam recordings in Germany.
GNU Affero General Public License v3.0
130 stars 27 forks source link

weight error #57

Closed Liriel-666 closed 1 year ago

Liriel-666 commented 1 year ago

(py38) C:\Anaconda3\DashcamCleaner\dashcamcleaner>python main.py YOLOv5 2022-12-29 Python-3.8.15 torch-1.13.1+cpu CPU

Traceback (most recent call last): File "C:\Users\Laen/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 49, in _create model = DetectMultiBackend(path, device=device, fuse=autoshape) # detection model File "C:\Users\Laen/.cache\torch\hub\ultralytics_yolov5_master\models\common.py", line 345, in init model = attempt_load(weights if isinstance(weights, list) else w, device=device, inplace=True, fuse=fuse) File "C:\Users\Laen/.cache\torch\hub\ultralytics_yolov5_master\models\experimental.py", line 79, in attempt_load ckpt = torch.load(attempt_download(w), map_location='cpu') # load File "C:\Anaconda3\envs\py38\lib\site-packages\torch\serialization.py", line 771, in load with _open_file_like(f, 'rb') as opened_file: File "C:\Anaconda3\envs\py38\lib\site-packages\torch\serialization.py", line 270, in _open_file_like return _open_file(name_or_buffer, mode) File "C:\Anaconda3\envs\py38\lib\site-packages\torch\serialization.py", line 251, in init super(_open_file, self).init(open(name, mode)) FileNotFoundError: [Errno 2] No such file or directory: 'C:\Anaconda3\DashcamCleaner\dashcamcleaner\weights\.pt.pt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\Laen/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 60, in _create model = attempt_load(path, device=device, fuse=False) # arbitrary model File "C:\Users\Laen/.cache\torch\hub\ultralytics_yolov5_master\models\experimental.py", line 79, in attempt_load ckpt = torch.load(attempt_download(w), map_location='cpu') # load File "C:\Anaconda3\envs\py38\lib\site-packages\torch\serialization.py", line 771, in load with _open_file_like(f, 'rb') as opened_file: File "C:\Anaconda3\envs\py38\lib\site-packages\torch\serialization.py", line 270, in _open_file_like return _open_file(name_or_buffer, mode) File "C:\Anaconda3\envs\py38\lib\site-packages\torch\serialization.py", line 251, in init super(_open_file, self).init(open(name, mode)) FileNotFoundError: [Errno 2] No such file or directory: 'C:\Anaconda3\DashcamCleaner\dashcamcleaner\weights\.pt.pt'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "main.py", line 256, in window = MainWindow() File "main.py", line 29, in init self.blur_wrapper = self.setup_blurrer() File "main.py", line 49, in setup_blurrer blur_wrapper = qtVideoBlurWrapper(weights_name, init_params) File "C:\Anaconda3\DashcamCleaner\dashcamcleaner\src\qt_wrapper.py", line 25, in init VideoBlurrer.init(self, weights_name, parameters) File "C:\Anaconda3\DashcamCleaner\dashcamcleaner\src\blurrer.py", line 33, in init self.detector = setup_detector(weights_path) File "C:\Anaconda3\DashcamCleaner\dashcamcleaner\src\blurrer.py", line 254, in setup_detector model = torch.hub.load("ultralytics/yolov5", "custom", weights_path, verbose=False) File "C:\Anaconda3\envs\py38\lib\site-packages\torch\hub.py", line 542, in load model = _load_local(repo_or_dir, model, *args, *kwargs) File "C:\Anaconda3\envs\py38\lib\site-packages\torch\hub.py", line 572, in _load_local model = entry(args, **kwargs) File "C:\Users\Laen/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 83, in custom return _create(path, autoshape=autoshape, verbose=_verbose, device=device) File "C:\Users\Laen/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 78, in _create raise Exception(s) from e Exception: [Errno 2] No such file or directory: 'C:\Anaconda3\DashcamCleaner\dashcamcleaner\weights\.pt.pt'. Cache may be out of date, try force_reload=True or see https://github.com/ultralytics/yolov5/issues/36 for help.

joshinils commented 1 year ago

The problems seems to be a doubling of the .pt extension. I already fixed this with a s.replace(".pt.pt", ".pt") for the cli variant, but not for the gui.

tfaehse commented 1 year ago

The PR somewhat addresses this. All uses of os.path have been replaced by the more modern pathlib, and errors with finding path files are actually displayed.