hhk7734 / tensorflow-yolov4

YOLOv4 Implemented in Tensorflow 2.
MIT License
136 stars 75 forks source link

would be better with more parameters #11

Closed pengKiina closed 4 years ago

pengKiina commented 4 years ago

it is a great work, could you add more parameters that would get the lib more applicable.

such as:

output_image = draw_bbox(img, bbox, label, conf)

result = yolo.draw_bboxes(original_image, pred_bboxes)
cv2.imwrite("result.jpg", result) 
from IPython.display import Image
Image("result.jpg")
hhk7734 commented 4 years ago

I'm doing something else now, so I'll check it after completion. :)

hhk7734 commented 4 years ago
def draw_bboxes(image: np.ndarray, bboxes: np.ndarray, classes: dict):
    """
    @parma image:  Dim(height, width, channel)
    @param bboxes: (candidates, 4) or (candidates, 5)
            [[center_x, center_y, w, h, class_id], ...]
            [[center_x, center_y, w, h, class_id, propability], ...]
    @param classes: {0: 'person', 1: 'bicycle', 2: 'car', ...}

    @return drawn_image

    Usage:
        image = media.draw_bboxes(image, bboxes, classes)
    """
classes = { class_id: label }

If you create classes and make bbox + label + conf to [x, y, w, h, label_id, conf], it seems to be what you want.

pengKiina commented 4 years ago

Thanks a lot.