Importing multiple images using cv2

asked 2018-09-01 02:15:45 -0600

Kafeel Basha gravatar image

Hello

After importing multiple images into python using cv2.imread(), I have stored the path corresponding to each image as a list using glob as below import glob files=glob.glob("D:\ML\Image processing\Cats and Dogs\\.jpg",recursive=True)

Now I would like to create a list to store the folder names corresponding to each image, like 'Cats', 'Dogs' by splitting the path, please help me with that.

edit retag flag offensive close merge delete

Comments

1

sorry, but splitting strings / pathes is basic python fu, and beyond the scope of this page. (get a book, do a course, learn something yourself, instead of asking around !)

berak gravatar imageberak ( 2018-09-01 02:58:14 -0600 )edit

Okay. Thanks

Kafeel Basha gravatar imageKafeel Basha ( 2018-09-01 03:55:03 -0600 )edit
1

glob will return a sorted list !

if it's the same dataset i have, then you know, that the 1st 600 are cats and the last 699 are dogs ;)

berak gravatar imageberak ( 2018-09-01 04:01:38 -0600 )edit