Sorry for my limited knowledge of AI. But I'm trying to use YOLOv2 (specifically darkflow) to identify my object. I have 100 images and have trained with 1000 epochs. However, my output is not really what the instructions I read online. There are too many bouding boxes to appear and I only have one object to identify in the picture. This is my test file. Also I would like to know the effect of 'threshold' in 'options'. Where is my problem currently located? Please let me know.
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)
Result image: