python - "No module named 'pathlib._local'; 'pathlib' is not a package" Error

im trying to use my best.pt model, but when i try to run it, it return this error :Exception has occur

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743986030a4538930.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信