Spaces:
Runtime error
Runtime error
Placeholder
Browse files
app.py
CHANGED
|
@@ -1,2 +1,23 @@
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
-
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
labels = ['apple', 'banana', 'beetroot', 'bell pepper', 'cabbage', 'capsicum', 'carrot', 'cauliflower', 'chilli pepper', 'corn', 'cucumber', 'eggplant', 'garlic', 'ginger', 'grapes', 'jalepeno', 'kiwi', 'lemon', 'lettuce', 'mango', 'onion', 'orange', 'paprika', 'pear', 'peas', 'pineapple', 'pomegranate', 'potato', 'raddish', 'soy beans', 'spinach', 'sweetcorn', 'sweetpotato', 'tomato', 'turnip', 'watermelon'] #learn.dls.vocab
|
| 5 |
+
|
| 6 |
+
probs=[9.9996e-01, 1.1584e-08, 1.8556e-07, 1.6986e-06, 3.5755e-08,
|
| 7 |
+
1.3057e-06, 2.7230e-08, 5.8373e-08, 1.3209e-08, 1.8147e-10,
|
| 8 |
+
2.8197e-08, 9.4939e-09, 8.8776e-09, 7.7736e-08, 3.0117e-08,
|
| 9 |
+
2.8444e-09, 9.8802e-09, 5.9252e-08, 1.9288e-08, 1.2375e-07,
|
| 10 |
+
8.2446e-08, 1.6437e-06, 2.4753e-08, 1.1622e-05, 6.6616e-09,
|
| 11 |
+
1.8746e-08, 1.6764e-05, 9.2635e-07, 2.6931e-09, 1.1366e-08,
|
| 12 |
+
1.7266e-09, 1.7419e-08, 3.6652e-08, 2.4264e-07, 8.6940e-08,
|
| 13 |
+
1.0518e-07]
|
| 14 |
+
|
| 15 |
+
def sample_predict(img):
|
| 16 |
+
img = PILImage.create(img)
|
| 17 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 18 |
+
|
| 19 |
+
intf=gr.Interface(fn=predict,
|
| 20 |
+
inputs=gr.inputs.Image(shape=(512, 512)),
|
| 21 |
+
outputs=gr.outputs.Label(num_top_classes=3))
|
| 22 |
+
|
| 23 |
+
intf.launch(share=True)
|