pytorch-yolo-v3 icon indicating copy to clipboard operation
pytorch-yolo-v3 copied to clipboard

Images are not being saved in the det folder

Open Magnetex opened this issue 6 years ago • 4 comments

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

Magnetex avatar Apr 27 '19 12:04 Magnetex

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.

snehilsanyal avatar Apr 30 '19 10:04 snehilsanyal

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

QizhengWu avatar May 10 '19 15:05 QizhengWu

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]))

CaptainKey avatar Jun 26 '19 16:06 CaptainKey

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

KaiWangCanada avatar Oct 22 '19 20:10 KaiWangCanada