forked from chandan2495/hackathon2016
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclassify_folder.py
30 lines (26 loc) · 935 Bytes
/
classify_folder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from test_imagenet import classify_image
import os
import sys
sys.path.insert(0, 'Scrapbook/python_scripts')
import superclass as sc
image_extensions = ["jpg", "jpeg", "png", "bmp"]
album_superclass_map = {
'animal' : 'Animal',
'person' : 'Person',
'location' : 'Places',
'vehicle' : 'Vehicles',
'sport' : 'Sports',
'geological_formation' : 'Outdoor',
'musical_instrument' : 'Musical Instruments',
'plant' : 'Nature',
'electronic_equipment' : 'Electronic Gadgets',
'misc' : 'Miscellaneous',
}
def classify_folder(dirpath):
for image in os.listdir(dirpath):
if image.split(".")[-1] in image_extensions:
print image
top_pred, out_label_preds= classify_image(dirpath + "\\"+ image)
print 'Image : {} , Label : {}'.format(image,top_pred['label'][1])
print 'Superclass : ', sc.getSuperClass(top_pred['label'][1])
classify_folder('G:\Hackathon\deep-learning-models\images\\awsome')