Reputation: 640
I am making an image classification CNN
for which I made a dataset. I have 4 different kinds of images:
Now I need to label my images so it can classify the problem on the image and try to repair it but I can't find an efficient way to select like all contrast and add a label.
I have already tried web applications like labelbox.io
but using that I have to do every image manually and I have too many images so doing that would just cost too much time.
Upvotes: 0
Views: 3970
Reputation: 2331
You didnt't provide that information but i will consider that your images' names are correctly formated in order to know in which category they belongs to.
So you can loop throught all of you data, and if they belong to a certain category, save the corresponding label in a list and save that list in a .csv :
labels = []
for img in os.listdir(IMG_FOLDER):
if 'contrast' in img: #if your image name contain 'contrast'
labels.append((img, 0))
elif 'noise' in img:
labels.append((img, 1))
elif 'jpeg' in img:
labels.append((img, 2))
elif 'unchanged' in img:
labels.append((img, 3))
labels = pd.DataFrame(labels, columns=['name', 'label'])
labels.to_csv('labels.csv', index=False)
Upvotes: 1