ultralytics / yolov5

YOLOv5 šŸš€ in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
49.95k stars 16.15k forks source link

Exception has occurred: NotImplementedError cannot instantiate 'PosixPath' on your system #10720

Closed V4A001 closed 1 year ago

V4A001 commented 1 year ago

Search before asking

YOLOv5 Component

Detection

Bug

After training I wanted to use the last.pt and best.pt. But both throw this 'PosixPath' exception. I tried using the provided models and they do not throw any error. python segment/predict.py --weights best.pt --source testimage.jpg

image

segment/train.py --device 0 --img 640 --cfg yolov5s-seg.yaml --hyp data/hyps/hyp.scratch-high.yaml --batch 16 --epochs 100 --data my.yaml --weights yolov5s-seg.pt

I am now trying training with yolov5l-seg.yaml to see if this makes a difference. I had working version with https://github.com/WongKinYiu/yolov7, but was not able to create a proper ONNX file. So now doing the same with this library. Previously I used Google Colab, but I believe that does not make the difference.

Environment

Minimal Reproducible Example

I used segment/train.py --device 0 --img 640 --cfg yolov5s-seg.yaml --hyp data/hyps/hyp.scratch-high.yaml --batch 16 --epochs 100 --data my.yaml --weights yolov5s-seg.pt

Additional

No response

Are you willing to submit a PR?

V4A001 commented 1 year ago

This issue does not occur in Google Colab. It is windows and this .pt file related.

akashAD98 commented 1 year ago

@V4A001 im also facing same, defult yolov5-cls.pt working but custom trained model not working

danielsoy commented 1 year ago

me too. I can predict.py in my local PC, only with a model trained locally. But got the same error, trying to predict locally, with best.pt or last.pt trained in Colab. The model trained in colab, predicts fine in colab.

github-actions[bot] commented 1 year ago

šŸ‘‹ Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 šŸš€ resources:

Access additional Ultralytics āš” resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 šŸš€ and Vision AI ā­!

glenn-jocher commented 10 months ago

Hey @danielsoy and @arreios, thanks for your reports. This issue might involve the way the file paths are handled in your local environment. You can try using the Path from the pathlib library to handle file paths in a platform-independent way. You can also check that the file paths you are using are correct and accessible. Let me know if you need further assistance. Remember, the YOLOv5 community is here to help each other out! šŸš€

Krushu24365 commented 7 months ago

yes i am with same error can anyone help with exact steps about how to do this

glenn-jocher commented 7 months ago

@Krushu24365 hello everyone, it seems like the issue might be related to the way file paths are handled across different operating systems. Here's a quick step you can try:

  1. Ensure that you're using string representations of the file paths when loading the weights. Instead of using a PosixPath object, convert it to a string.

For example, if you have:

weights_path = Path('best.pt')

Convert it to a string like this:

weights_path = str(Path('best.pt'))

Then use weights_path as the argument for loading weights.

If you continue to encounter issues, please ensure that your environment is set up correctly and that the file paths are accessible. If the problem persists, providing the exact error message and the code snippet where the error occurs could help us diagnose the issue more effectively. šŸ› ļø