首页 / 浏览问题 / 桌面GIS / 问题详情
机器学习目标检测模型训练成功后,用模型进行目标检测推理待推理影像失败
28EXP 2024年07月01日
>>> runfile(r'C:\Users\admin\AppData\Local\Temp\ml-process_objectdetection_27.py')
PyDev console: starting.

Python 3.8.16 | packaged by conda-forge | (default, Feb  1 2023, 15:53:35) [MSC v.1929 64 bit (AMD64)] 
[iObjectsPy]: The Gateway service started successfully

Traceback (most recent call last):
  File "<input>", line 1, in <module>
[07/01 10:55:43 d2.checkpoint.detection_checkpoint]: [DetectionCheckpointer] Loading from E:\yaogantest\self-running-training\Tank training\tank\saved_model_fast-20-1-0.001\saved_model_fast-20-1-0.pth ...
  File "C:\SuperMap\SuperMap iDesktopX 11i\resources\python-helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "C:\SuperMap\SuperMap iDesktopX 11i\resources\python-helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:\Users\admin\AppData\Local\Temp\ml-process_objectdetection_27.py", line 13, in <module>
    ImageryInference(model_path=r"E:\yaogantest\self-running-training\Tank training\tank\saved_model_fast-20-1-0.001\saved_model_fast-20-1-0.001.sdm",nms_thresh=0.3,score_thresh=0.2,gpus=[0],batch_size=int(1)).object_detect_infer(input_data=dataset,out_data=datasource,out_dataset_name=r"Ob_fast_20",category_name=None,infer_region=None)
  File "I:\teamctiy\BuildAgent\work\test_111x/iobjectspy/ml\vision\_inference.py", line 72, in __init__
  File "I:\teamctiy\BuildAgent\work\test_111x/iobjectspy/ml\vision\_inference_collector\object_detection_infer.py", line 20, in __init__
  File "I:\teamctiy\BuildAgent\work\test_111x/iobjectspy/ml\vision\_inference_collector\object_detection_infer.py", line 58, in load_model
  File "I:\teamctiy\BuildAgent\work\test_111x/iobjectspy/ml\vision\_models\object_detection\_torch_models\ob_inference_base.py", line 50, in __init__
  File "I:\teamctiy\BuildAgent\work\test_111x/iobjectspy/ml\vision\_models\object_detection\_torch_models\inference_detectron.py", line 46, in load_model
  File "E:\yaogan\environment\conda\lib\site-packages\detectron2\engine\defaults.py", line 288, in __init__
    checkpointer.load(cfg.MODEL.WEIGHTS)
  File "E:\yaogan\environment\conda\lib\site-packages\detectron2\checkpoint\detection_checkpoint.py", line 62, in load
    ret = super().load(path, *args, **kwargs)
  File "E:\yaogan\environment\conda\lib\site-packages\fvcore\common\checkpoint.py", line 153, in load
    assert os.path.isfile(path), "Checkpoint {} not found!".format(path)
AssertionError: Checkpoint e:\yaogantest\self-running-training\Tank training\tank\saved_model_fast-20-1-0.001\saved_model_fast-20-1-0.pth not found!

1个回答

AssertionError: Checkpoint e:\yaogantest\self-running-training\Tank training\tank\saved_model_fast-20-1-0.001\saved_model_fast-20-1-0.pth not found!

报错提示文件路径未找到,排查该文件路径是否存在,以及执行的相对路径是否正确
1,505EXP 2024年07月01日
您好 我这边文件存在 路径也是正确的 我这边上传不了图片 截图私发给您 麻烦再帮我看一下什么问题好吗
两点排查建议:

1、用记事本工具打开pth文件,看看内部是否有指定某个骨干网络文件,其中是否是相对路径

2、建议在python环境窗口,逐行执行,指定正确的相对路径目录
...