{"action":"created","issue":{"url":"https://api.github.com/repos/pjreddie/darknet/issues/116","repository_url":"https://api.github.com/repos/pjreddie/darknet","labels_url":"https://api.github.com/repos/pjreddie/darknet/issues/116/labels{/name}","comments_url":"https://api.github.com/repos/pjreddie/darknet/issues/116/comments","events_url":"https://api.github.com/repos/pjreddie/darknet/issues/116/events","html_url":"https://github.com/pjreddie/darknet/issues/116","id":247069501,"number":116,"title":"Running detection on multiple images with Python - Memory leak?","user":{"login":"jonathangranskog","id":7887401,"avatar_url":"https://avatars2.githubusercontent.com/u/7887401?v=4","gravatar_id":"","url":"https://api.github.com/users/jonathangranskog","html_url":"https://github.com/jonathangranskog","followers_url":"https://api.github.com/users/jonathangranskog/followers","following_url":"https://api.github.com/users/jonathangranskog/following{/other_user}","gists_url":"https://api.github.com/users/jonathangranskog/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathangranskog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathangranskog/subscriptions","organizations_url":"https://api.github.com/users/jonathangranskog/orgs","repos_url":"https://api.github.com/users/jonathangranskog/repos","events_url":"https://api.github.com/users/jonathangranskog/events{/privacy}","received_events_url":"https://api.github.com/users/jonathangranskog/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-01T13:29:22Z","updated_at":"2017-08-18T07:02:25Z","closed_at":"2017-08-18T07:02:25Z","body":"I am testing the Python API to run detection on thousands of images after each other and I've found that the memory keeps increasing over time until filling it. I haven't experienced similar problems using the C code directly. I am on Ubuntu 14.04. \r\n\r\nHere's the python script I am running:\r\n```\r\nimport python.darknet\r\nimport os, sys\r\n\r\nnet = python.darknet.load_net(\"cfg/yolo.cfg\", \"weights/yolo.weights\", 0)\r\nmeta = python.darknet.load_meta(\"cfg/coco.data\")\r\n\r\nfolder = sys.argv[1]\r\nfiles = os.listdir(folder)\r\n\r\nfor f in files:\r\n    if f.endswith(\".jpg\") or f.endswith(\".jpeg\") or f.endswith(\".png\"):\r\n        print f\r\n        path = os.path.join(folder, f)\r\n        im = python.darknet.load_image(path, 0, 0)\r\n        res = python.darknet.detect(net, meta, im)\r\n\tprint res[:3]\r\n```\r\nIs it a memory leak? Or is there something else I should consider when running on multiple images in a row?"},"comment":{"url":"https://api.github.com/repos/pjreddie/darknet/issues/comments/323276538","html_url":"https://github.com/pjreddie/darknet/issues/116#issuecomment-323276538","issue_url":"https://api.github.com/repos/pjreddie/darknet/issues/116","id":323276538,"user":{"login":"jonathangranskog","id":7887401,"avatar_url":"https://avatars2.githubusercontent.com/u/7887401?v=4","gravatar_id":"","url":"https://api.github.com/users/jonathangranskog","html_url":"https://github.com/jonathangranskog","followers_url":"https://api.github.com/users/jonathangranskog/followers","following_url":"https://api.github.com/users/jonathangranskog/following{/other_user}","gists_url":"https://api.github.com/users/jonathangranskog/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathangranskog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathangranskog/subscriptions","organizations_url":"https://api.github.com/users/jonathangranskog/orgs","repos_url":"https://api.github.com/users/jonathangranskog/repos","events_url":"https://api.github.com/users/jonathangranskog/events{/privacy}","received_events_url":"https://api.github.com/users/jonathangranskog/received_events","type":"User","site_admin":false},"created_at":"2017-08-18T07:02:25Z","updated_at":"2017-08-18T07:02:25Z","body":"Ok I solved this by adding a function which takes as input the byte array of an image from python and then creating an image object from it and freeing it when detection is completed. "}}
{"actor":{"display_login":"jonathangranskog"}}