如何解决使用Google Colab上的pytorch在detectron2中进行对象检测重用已经训练的模型或导入现有的训练模型并预测对象
- 首先,我下载经过训练的模型的输出文件夹,并将其导入google colab服务器上的新项目中。
- 在没有训练模型的新项目中,我将现有输出文件夹的
model_final.pth
的路径指定为cfg.MODEL.WEIGHTS
= / content / output / model_final.pth。但陷入无限循环。 3.我更改模型权重cfg.MODEL.WEIGHTS = "detectron2://COCO-Detection/faster_rcnn_R_101_FPN_3x/137851257/model_final_f6e8b1.pkl"
。但仍然不能预测对象。 - 我更改了模型权重路径,并提供了先前训练过的模型指标
JSON
文件,但仍然无法正常工作cfg.MODEL.WEIGHTS=/content/output/metrics.json 5.By using DetectionCheckpointer(model).load("/content/output/model_final.pth") DetectionCheckpointer(model).load("detectron2://COCO-Detection/faster_rcnn_R_101_FPN_3x/137851257/model_final_f6e8b1.pkl")
它给出了未定义的错误模型。 这个model_final.pkl
文件是什么?我们从哪里得到的? 应该如何导入现有的火车模型并预测新项目中的对象?
cfg.MODEL.WEIGHTS = os.path.join(cfg.OUTPUT_DIR,"model_final.pth")
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5
cfg.DATASETS.TEST = ("microcontroller_test",)
predictor = DefaultPredictor(cfg)
以上代码陷入无限循环
DetectionCheckpointer(model).load("/content/output/model_final.pth")
DetectionCheckpointer(model).load("detectron2://COCO-Detection/faster_rcnn_R_101_FPN_3x/137851257/model_final_f6e8b1.pkl")
错误:
NameError Traceback (most recent call last)
<ipython-input-12-69f2a7846756> in <module>()
----> 1 DetectionCheckpointer(model).load("/content/output/model_final.pth")
2
3 DetectionCheckpointer(model).load("detectron2://COCO-Detection/faster_rcnn_R_101_FPN_3x/137851257/model_final_f6e8b1.pkl")
NameError: name 'model' is not defined
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。