From e5e4171c7875609a01560ea4d1cdeb81732614fc Mon Sep 17 00:00:00 2001 From: betegon Date: Tue, 29 Sep 2020 11:29:22 +0200 Subject: [PATCH] Refactor to make clean code --- darknet.py | 1 + darknet_images.py | 1 - darknet_video.py | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/darknet.py b/darknet.py index ad526f99d95..8be5f81ee54 100644 --- a/darknet.py +++ b/darknet.py @@ -175,6 +175,7 @@ def detect_image(network, class_names, image, thresh=.5, hier_thresh=.5, nms=.45 predictions = remove_negatives(detections, class_names, num) predictions = decode_detection(predictions) free_detections(detections, num) + free_image(image) return sorted(predictions, key=lambda x: x[1]) diff --git a/darknet_images.py b/darknet_images.py index 0b07689e4c6..113489e2340 100644 --- a/darknet_images.py +++ b/darknet_images.py @@ -111,7 +111,6 @@ def image_detection(image_path, network, class_names, class_colors, thresh): darknet.copy_image_from_bytes(darknet_image, image_resized.tobytes()) detections = darknet.detect_image(network, class_names, darknet_image, thresh=thresh) - darknet.free_image(darknet_image) image = darknet.draw_boxes(detections, image_resized, class_colors) return cv2.cvtColor(image, cv2.COLOR_BGR2RGB), detections diff --git a/darknet_video.py b/darknet_video.py index 44e4b4fc1e4..de96d709ed1 100644 --- a/darknet_video.py +++ b/darknet_video.py @@ -84,7 +84,6 @@ def inference(darknet_image_queue, detections_queue, fps_queue): fps_queue.put(fps) print("FPS: {}".format(fps)) darknet.print_detections(detections, args.ext_output) - darknet.free_image(darknet_image) cap.release()