procodec commited on
Commit
814d9cc
·
1 Parent(s): 8043d48

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +65 -0
app.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.learner import *
2
+ from fastai.vision.all import *
3
+ import gradio as gr
4
+
5
+ learn = load_learner("export.pkl")
6
+ labels = learn.dls.vocab
7
+
8
+ def predict(img):
9
+ img = PILImage.create(img)
10
+ pred,pred_idx,probs = learn.predict(img)
11
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
12
+ title = "Garbage Classifier [Squeeze Net]"
13
+ description = " Created as a demo for Gradio and HuggingFace Spaces."
14
+ article="<p style='text-align: center'><a href='https://recycleye.com/wastenet/' target='_blank'>Link to ISIC Dataset</a></p>"
15
+ interpretation='default'
16
+ enable_queue=True
17
+ examples = examples=['img1.jpg','img2.jpg','img3.jpg','img4.jpg']
18
+
19
+ gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+ # import gradio as gr
37
+ # from fastai.vision.all import *
38
+ # import skimage
39
+ # #Importing necessary libraries
40
+ # import gradio as gr
41
+ # #import scikit-learn as sklearn
42
+ # from fastai.vision.all import *
43
+ # from sklearn.metrics import roc_auc_score
44
+
45
+ # learn = load_learner('export.pkl')
46
+
47
+ # labels = learn.dls.vocab
48
+ # def predict(img):
49
+ # img = PILImage.create(img)
50
+ # pred,pred_idx,probs = learn.predict(img)
51
+ # return {labels[i]: float(probs[i]) for i in range(len(labels))}
52
+
53
+
54
+ # examples = ['img1.jpg','img2.jpg','img3.jpg']
55
+
56
+ # #Launching the gradio application
57
+ # gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),
58
+ # outputs=gr.outputs.Label(num_top_classes=1),
59
+ # title=title,
60
+ # description=description,article=article,
61
+ # examples=examples,
62
+ # enable_queue=enable_queue).launch(inline=False)
63
+
64
+ # #gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(224, 224)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
65
+