thtrieu / darkflow

Translate darknet to tensorflow. Load trained weights, retrain/fine-tune using tensorflow, export constant graph def to mobile devices
GNU General Public License v3.0
6.13k stars 2.08k forks source link

Parsing output without using "return_predict()" #1084

Open anoob09 opened 5 years ago

anoob09 commented 5 years ago

I am getting a numpy array of dimension (19, 19, 30) as my output. I want to parse the output on my own without using the return_predict() present inside flow.py file. Can anyone explain me the output or help me get the bounding boxes?

Rishabh-Maheshwari commented 4 years ago

Pass the result numpy array and image to the following function:

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.3:
        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