Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Free image memory in Python darknet.py #6760

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions darknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,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])


Expand Down
1 change: 0 additions & 1 deletion darknet_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def image_detection(image_or_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

Expand Down
2 changes: 1 addition & 1 deletion darknet_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def inference(stop_flag, preprocessed_frame_queue, detections_queue, fps_queue,
fps_queue.put(int(fps))
print("FPS: {:.2f}".format(fps))
darknet.print_detections(detections, args.ext_output)
darknet.free_image(darknet_image)
cap.release()


def drawing(stop_flag, input_video_fps, queues, preproc_h, preproc_w, vid_h, vid_w):
Expand Down