Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
|
4 |
+
learn = load_learner('car-model.pkl')
|
5 |
+
categories = ['Porsche', 'Mercedes', 'Other']
|
6 |
+
|
7 |
+
def classify_image(img):
|
8 |
+
pred, idx, probs = learn.predict(img)
|
9 |
+
return dict(zip(categories, map(float, probs)))
|
10 |
+
|
11 |
+
image = gr.inputs.Image(shape=(224, 224))
|
12 |
+
label = gr.outputs.Label()
|
13 |
+
|
14 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label)
|
15 |
+
intf.launch(inline=False)
|