arunslb123 commited on
Commit
5fea6c7
·
1 Parent(s): 303d1a9

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+
4
+ learn = load_learner("export.pkl")
5
+
6
+ labels = learn.dls.vocab
7
+
8
+
9
+ def predict(img):
10
+ img = PILImage.create(img)
11
+ pred, pred_idx, probs = learn.predict(img)
12
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+
15
+ title = "Car or Bike Classifier"
16
+ description = "A Car or Bike or not classifier trained with downloaded data from internet. Created as a demo for Gradio and HuggingFace Spaces."
17
+
18
+ examples = ["cars.jpg", "bike.jpg"]
19
+ interpretation = "default"
20
+ enable_queue = True
21
+
22
+ gr.Interface(
23
+ fn=predict,
24
+ inputs=gr.inputs.Image(shape=(512, 512)),
25
+ outputs=gr.outputs.Label(num_top_classes=2),
26
+ title=title,
27
+ description=description,
28
+ examples=examples,
29
+ interpretation=interpretation,
30
+ enable_queue=enable_queue,
31
+ ).launch(share=True)