Aravindan commited on
Commit
81909d9
·
1 Parent(s): c86889b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +91 -0
app.py CHANGED
@@ -11,6 +11,97 @@ checkpoint = torch.load('model_best_checkpoint.pth.tar')
11
  new_model.load_state_dict(checkpoint['model'])
12
  new_model.to(device)
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
 
16
 
 
11
  new_model.load_state_dict(checkpoint['model'])
12
  new_model.to(device)
13
 
14
+ we_are = ['INDRA SWALLOW',
15
+ 'MALACHITE',
16
+ 'COMMON BANDED AWL',
17
+ 'DANAID EGGFLY',
18
+ 'EASTERN PINE ELFIN',
19
+ 'YELLOW SWALLOW TAIL',
20
+ 'WOOD SATYR',
21
+ 'ULYSES',
22
+ 'MESTRA',
23
+ 'MANGROVE SKIPPER',
24
+ 'BECKERS WHITE',
25
+ 'CRECENT',
26
+ 'RED SPOTTED PURPLE',
27
+ 'SOOTYWING',
28
+ 'BLACK HAIRSTREAK',
29
+ 'STRAITED QUEEN',
30
+ 'ELBOWED PIERROT',
31
+ 'ORANGE OAKLEAF',
32
+ 'CHESTNUT',
33
+ 'POPINJAY',
34
+ 'COMMON WOOD-NYMPH',
35
+ 'BROWN SIPROETA',
36
+ 'QUESTION MARK',
37
+ 'ADONIS',
38
+ 'CLOUDED SULPHUR',
39
+ 'TWO BARRED FLASHER',
40
+ 'GOLD BANDED',
41
+ 'BANDED ORANGE HELICONIAN',
42
+ 'PURPLISH COPPER',
43
+ 'VICEROY',
44
+ 'RED CRACKER',
45
+ 'SILVER SPOT SKIPPER',
46
+ 'ZEBRA LONG WING',
47
+ 'ORCHARD SWALLOW',
48
+ 'RED POSTMAN',
49
+ 'SOUTHERN DOGFACE',
50
+ 'SCARCE SWALLOW',
51
+ 'EASTERN COMA',
52
+ 'CAIRNS BIRDWING',
53
+ 'GREEN CELLED CATTLEHEART',
54
+ 'METALMARK',
55
+ 'LARGE MARBLE',
56
+ 'AMERICAN SNOOT',
57
+ 'COPPER TAIL',
58
+ 'AN 88',
59
+ 'AFRICAN GIANT SWALLOWTAIL',
60
+ 'PAPER KITE',
61
+ 'EASTERN DAPPLE WHITE',
62
+ 'PEACOCK',
63
+ 'ATALA',
64
+ 'JULIA',
65
+ 'RED ADMIRAL',
66
+ 'GREAT JAY',
67
+ 'GREAT EGGFLY',
68
+ 'GREY HAIRSTREAK',
69
+ 'PIPEVINE SWALLOW',
70
+ 'PURPLE HAIRSTREAK',
71
+ 'ORANGE TIP',
72
+ 'BLUE SPOTTED CROW',
73
+ 'TROPICAL LEAFWING',
74
+ 'CLEOPATRA',
75
+ 'APPOLLO',
76
+ 'IPHICLUS SISTER',
77
+ 'CABBAGE WHITE',
78
+ 'BANDED PEACOCK',
79
+ 'MONARCH',
80
+ 'CRIMSON PATCH',
81
+ 'BLUE MORPHO',
82
+ 'MOURNING CLOAK',
83
+ 'SLEEPY ORANGE',
84
+ 'CLODIUS PARNASSIAN',
85
+ 'MILBERTS TORTOISESHELL',
86
+ 'PINE WHITE',
87
+ 'CHECQUERED SKIPPER',
88
+ 'PAINTED LADY']
89
+
90
+ def classify(image_):
91
+ model = model.eval()
92
+ image = Image.open(image_)
93
+ image = image_transforms(image).float().to(device)
94
+ image = image.unsqueeze(0)
95
+ output = model(image)
96
+
97
+ _, predicted = torch.max(output, 1)
98
+ return we_are[predicted]
99
+
100
+
101
+ label = gr.outputs.Label(num_top_classes=75)
102
+ gr.Interface(fn=classify, inputs='image', outputs=label,interpretation='default', title = 'Butterfly Classification detection ', description = 'It will classify 75 different species ').launch()
103
+
104
+
105
 
106
 
107