|
| str | cfg_file = "../cfg/yolov4-tiny.cfg" |
| |
| | class_names = open(names_file).read().splitlines() |
| |
| | colours = darknet.class_colors(class_names) |
| |
| | darknet_image = darknet.make_image(width, height, 3) |
| |
| | detections = darknet.detect_image(network, class_names, darknet_image, thresh=prediction_threshold) |
| |
| | height = darknet.network_height(network) |
| |
| | image_bgr = cv2.imread(filename) |
| |
| | image_resized = cv2.resize(image_rgb, (width, height), interpolation=cv2.INTER_LINEAR) |
| |
| | image_rgb = cv2.cvtColor(image_bgr, cv2.COLOR_BGR2RGB) |
| |
| | image_with_boxes = darknet.draw_boxes(detections, image_resized, colours) |
| |
| str | log_file = "output.log" |
| |
| str | names_file = "../cfg/coco.names" |
| |
| | network = darknet.load_net_custom(cfg_file.encode("ascii"), weights_file.encode("ascii"), 0, 1) |
| |
| float | prediction_threshold = 0.5 |
| |
| str | weights_file = "../yolov4-tiny.weights" |
| |
| | width = darknet.network_width(network) |
| |
This is EXAMPLE python code showing how to use the Python darknet module.
It is NOT a final application! You must modify this example to make it do what you need.