pytorch-yolo-v3
pytorch-yolo-v3 copied to clipboard
Images are not being saved in the det folder
The command 'python detect.py --images imgs --det det' is creating the det folder but the images are not being saved The detector is running perfectly. It is detecting all the objects but the images with the bounding boxes are not being saved in the det folder
Hey Magnetex. I needed the frames to be saved only one at a time for my implementation so I modified the code in detect.py. This will only save the current detected image as a file name in det folder so that you can have all the possibilities of the detection. Try adding this code in the def write(x, batches, results): #Include the path for the images path = "D:/pytorch_test_2/pytorch-yolo-v3/det" cv2.imwrite(os.path.join(path,"detected_image.jpg"), img) cv2.imshow("Image detected", img) #Image is saved after every key hit key = cv2.waitKey(0) Hope this helps. You can add a counter which will save the image as detected_image_0 or detected_image_1 as we hit any button on the OpenCV screen. This is my first comment on GitHub.
I add the chunk you provided at the end of the "def write (x, batches, results):" part and modify the "path" to my own path, but it seems that the images in "imgs" still cannot be saved into "det" when I run the detect.py in my Anaconda Prompt in Windows system. Can you please offer some more advice? Thanks a lot. @snehilsanyal
Hi,
I had the same issue. This is my solution :
In detect.py at line 302 you have
det_names = pd.Series(imlist).apply(lambda x: "{}/det_{}".format(args.det,x.split("/")[-1]))
change it to
det_names = pd.Series(imlist).apply(lambda x: "{}/det_{}".format(args.det,x.split("\\")[-1]))
Hi,
I had the same issue. This is my solution :
In detect.py at line 302 you have
det_names = pd.Series(imlist).apply(lambda x: "{}/det_{}".format(args.det,x.split("/")[-1]))change it to
det_names = pd.Series(imlist).apply(lambda x: "{}/det_{}".format(args.det,x.split("\\")[-1]))
Thanks, Captain