Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""app.py
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1LaNr93cDE2Yu0K0Ggezux4KGGyygFGlg
|
8 |
+
"""
|
9 |
+
|
10 |
+
import gradio as gr
|
11 |
+
from fastai.vision.all import *
|
12 |
+
learn=load_learner('export.pkl')
|
13 |
+
|
14 |
+
labels = learn.dls.vocab
|
15 |
+
def predict(img):
|
16 |
+
img = PILImage.create(img)
|
17 |
+
pred,pred_idx,probs = learn.predict(img)
|
18 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
19 |
+
title='Emergency Vehicle Classifier'
|
20 |
+
interpretation='default'
|
21 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3), title=title, interpretation=interpretation).launch(share=True)
|