robinsk8a commited on
Commit
25f9bd0
·
1 Parent(s): ba956c5

Gradio app actualized with examples, title, image recognition and description

Browse files
Files changed (5) hide show
  1. app.py +17 -4
  2. bmw.jpg +0 -0
  3. koenigsegg.jpg +0 -0
  4. lamborghini.jpg +0 -0
  5. requirements.txt +2 -0
app.py CHANGED
@@ -1,7 +1,20 @@
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
  import gradio as gr
3
 
4
+ learn = load_learner('sport_car_classifier.pkl')
5
+ labels = learn.dls.vocab
6
+ def predict(img):
7
+ img = PILImage.create(img)
8
+ pred,pred_idx,probs = learn.predict(img)
9
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
10
 
11
+ gr.Interface(
12
+ fn=predict,
13
+ inputs=gr.inputs.Image(
14
+ shape=(512, 512)),
15
+ outputs=gr.outputs.Label(num_top_classes=3),
16
+ title="Sport car classifier",
17
+ description="An app design to classifie the most relateve sportcars",
18
+ examples=['bmw.jpg', 'lamborghini.jpg', 'koenigsegg.jpg'],
19
+ interpretation='default',
20
+ enable_queue=True).launch(share=True)
bmw.jpg ADDED
koenigsegg.jpg ADDED
lamborghini.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image