admin 管理员组

文章数量: 1086864

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

本文标签:

Error[2]: Invalid argument supplied for foreach(), File: /www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm, Line: 58
File: /www/wwwroot/roclinux.cn/tmp/route_read.php, Line: 205, include(/www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm)
File: /www/wwwroot/roclinux.cn/tmp/index.inc.php, Line: 129, include(/www/wwwroot/roclinux.cn/tmp/route_read.php)
File: /www/wwwroot/roclinux.cn/index.php, Line: 29, include(/www/wwwroot/roclinux.cn/tmp/index.inc.php)