im trying to use my best.pt
model, but when i try to run it, it return this error :
Exception has occurred: ModuleNotFoundError
No module named 'pathlib._local'; 'pathlib' is not a package
AttributeError: module 'pathlib' has no attribute '__path__'
During handling of the above exception, another exception occurred:
File "C:\Users\masso\Desktop\yolov5-master-v7\main.py", line 147, in _load_model
model = torch.load('best.pt', map_location=self.device)
File "C:\Users\masso\Desktop\yolov5-master-v7\main.py", line 57, in __init__
self.model = self._load_model()
File "C:\Users\masso\Desktop\yolov5-master-v7\main.py", line 354, in main
detector = ObjectDetector()
File "C:\Users\masso\Desktop\yolov5-master-v7\main.py", line 358, in <module>
main()
ModuleNotFoundError: No module named 'pathlib._local'; 'pathlib' is not a package
Here is the script i use to import my model :
def _load_model(self):
"""load yolov5"""
try:
model = torch.load('best.pt', map_location=self.device)
model.to(self.device)
model.half()
model.eval()
model.conf = 0.4
model.iou = 0.45
return model
except Exception as e:
print(f"Error: {e}")
raise
How to resolve this?
System info:
Python: 3.8
CUDA Version: 11.8