yolov7_d2 icon indicating copy to clipboard operation
yolov7_d2 copied to clipboard

How to save the model to run on different directory folder.

Open gkpodder opened this issue 3 years ago • 2 comments

I trained the model(image segmentation) and got the .pth file and config file. I tried to transfer those files over to my other laptop and ran it with the yolov7 folder there but I get errors

PytorchStreamReader failed reading zip archive: failed finding central directory

I believe this is because it doesn't save it properly and must be kept in the original directory?

Is there a way for me to save it properly to use it in the demo.py file in a different computer?

When I tried running the demo file on colab(original directory for when it was trained) it ran so I think it might be cuz its not in the original dir.

gkpodder avatar Jul 25 '22 20:07 gkpodder

using --opts MODEL.WEIGHTS to specific weights location. Your pth might truncated if can not load. check it first.

lucasjinreal avatar Jul 26 '22 02:07 lucasjinreal

@jinfagang here is the error output from my terminal: PS C:\Users\gkpod\Desktop\yolov7-main> & c:/Users/gkpod/Desktop/yolov7-main/env/Scripts/Activate.ps1 (env) PS C:\Users\gkpod\Desktop\yolov7-main> python demo.py --config-file config.yaml --input image_t5.jpg -c 0.55 --output detectasd --opts MODEL.WEIGHTS model_final.pth
Install mish-cuda to speed up training and inference. More importantly, replace the naive Mish with MishCuda will give a ~1.5G memory saving during training. [07/27 14:18:03 detectron2]: Arguments: Namespace(config_file='config.yaml', webcam=False, input='image_t5.jpg', output='detectasd', confidence_threshold=0.55, nms_threshold=0.6, wandb_project=None, wandb_entity=None, opts=['MODEL.WEIGHTS', 'model_final.pth']) 14:18:03 07.27 INFO yolomask.py:86]: YOLO.ANCHORS: [[142, 110], [192, 243], [459, 401], [36, 75], [76, 55], [72, 146], [12, 16], [19, 36], [40, 28]] 14:18:03 07.27 INFO yolomask.py:89]: backboneshape: [64, 128, 256, 512], size_divisibility: 32 [[142, 110], [192, 243], [459, 401], [36, 75], [76, 55], [72, 146], [12, 16], [19, 36], [40, 28]] [07/27 14:18:03 fvcore.common.checkpoint]: [Checkpointer] Loading from model_final.pth ... Traceback (most recent call last): File "C:\Users\gkpod\Desktop\yolov7-main\demo.py", line 199, in predictor = DefaultPredictor(cfg) File "C:\Users\gkpod\Desktop\yolov7-main\demo.py", line 38, in init checkpointer.load(cfg.MODEL.WEIGHTS) File "c:\users\gkpod\desktop\yolov7-main\detectron2\detectron2\checkpoint\detection_checkpoint.py", line 52, in load ret = super().load(path, *args, **kwargs) File "C:\Users\gkpod\Desktop\yolov7-main\env\lib\site-packages\fvcore\common\checkpoint.py", line 155, in load checkpoint = self._load_file(path) File "c:\users\gkpod\desktop\yolov7-main\detectron2\detectron2\checkpoint\detection_checkpoint.py", line 88, in _load_file loaded = super()._load_file(filename) # load native pth checkpoint File "C:\Users\gkpod\Desktop\yolov7-main\env\lib\site-packages\fvcore\common\checkpoint.py", line 254, in _load_file return torch.load(f, map_location=torch.device("cpu")) File "C:\Users\gkpod\Desktop\yolov7-main\env\lib\site-packages\torch\serialization.py", line 585, in load with _open_zipfile_reader(opened_file) as opened_zipfile: File "C:\Users\gkpod\Desktop\yolov7-main\env\lib\site-packages\torch\serialization.py", line 242, in init super(_open_zipfile_reader, self).init(torch._C.PyTorchFileReader(name_or_buffer)) RuntimeError: [enforce fail at ..\caffe2\serialize\inline_container.cc:145] . PytorchStreamReader failed reading zip archive: failed finding central directory

gkpodder avatar Jul 27 '22 18:07 gkpodder