对不起,我对 AI 的了解有限。但我正在尝试使用 YOLOv2(特别是暗流)来识别我的对象。我有 100 张图像,并且已经训练了 1000 个 epoch。但是,我的输出并不是我在网上阅读的说明。有太多的边界框要出现,我只有一个物体可以在图片中识别。这是我的测试文件。另外我想知道“选项”中“阈值”的影响。我的问题目前在哪里?请告诉我。
from darkflow.net.build import TFNet
import numpy as np
import cv2
import time
import pprint as pp
options = {
"model": "cfg/yolov2-voc-1c.cfg",
"load": -1,
"threshold": 0.01
}
tfnet2 = TFNet(options)
tfnet2.load_from_ckpt()
def boxing(original_img, predictions):
newImage = np.copy(original_img)
for result in predictions:
top_x = result['topleft']['x']
top_y = result['topleft']['y']
btm_x = result['bottomright']['x']
btm_y = result['bottomright']['y']
confidence = result['confidence']
label = result['label'] + " " + str(round(confidence, 3))
if confidence > 0.06:
newImage = cv2.rectangle(newImage, (top_x, top_y), (btm_x, btm_y), (255,0,0), 3)
newImage = cv2.putText(newImage, label, (top_x, top_y-5), cv2.FONT_HERSHEY_COMPLEX_SMALL , 0.8, (0, 230, 0), 1, cv2.LINE_AA)
return newImage
original_img = cv2.imread("data_test.jpg")
original_img = cv2.cvtColor(original_img, cv2.COLOR_BGR2RGB)
result = tfnet2.return_predict(original_img)
new_frame = boxing(original_img, result)
cv2.imwrite('output.jpg', new_frame)
结果图片: