Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何更改和使用Pytorch训练的缩放Yolov4权重以在Opencv中使用(作为.weights文件)?_Python_Opencv_Deep Learning_Computer Vision_Pytorch - Fatal编程技术网

Python 如何更改和使用Pytorch训练的缩放Yolov4权重以在Opencv中使用(作为.weights文件)?

Python 如何更改和使用Pytorch训练的缩放Yolov4权重以在Opencv中使用(作为.weights文件)?,python,opencv,deep-learning,computer-vision,pytorch,Python,Opencv,Deep Learning,Computer Vision,Pytorch,我在我的图像上训练了一个缩放的YOLO v4模型,并得到了模型权重,其形式为best_yolov4-csp-results.pt 使用Yolov4中的DarkNet权重,我得到的权重为.weights,我可以用来读取和给出预测,如下所示: net = cv2.dnn.readNet("./yolov4-obj_best_1_class.weights", "./yolov4-custom_1_class.cfg") model = cv2.dnn_Dete

我在我的图像上训练了一个缩放的YOLO v4模型,并得到了模型权重,其形式为
best_yolov4-csp-results.pt

使用Yolov4中的
DarkNet
权重,我得到的权重为
.weights
,我可以用来读取和给出预测,如下所示:

net = cv2.dnn.readNet("./yolov4-obj_best_1_class.weights", "./yolov4-custom_1_class.cfg")
model = cv2.dnn_DetectionModel(net)
model.setInputParams(size=(416, 416),scale=1/255.)
classes, scores, boxes = model.detect(img_array, 0.51, 0.51)

我的问题是,如何对当前的
pytorch\u weights.pt
文件执行相同的操作

或者,如果不可能,如何仅使用
Pytorch
为每个映像部署模型