Spaces:
Running
Running
File size: 904 Bytes
8fae8d6 5ee2f39 8fae8d6 5ee2f39 8fae8d6 c3471a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
from fastai.vision.all import *
from fastai.vision.all import load_learner
import gradio as gr
fruit_labels = ('Apple', 'Apricot', 'Avocado',
'Banana', 'Blueberry',
'Carambola', 'Cherry', 'Fig',
'Grape', 'Kiwi', 'Lemon',
'Lychee', 'Mango',
'Orange', 'Papaya',
'Pear', 'Pineapple',
'Raspberry', 'Strawberry', 'Watermelon')
model=load_learner("fruit_model_v6.pkl")
def recognize_image(image):
pred, idx, probs = model.predict(image)
print(pred)
return dict(zip(fruit_labels, map(float, probs)))
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label(num_top_classes=5)
examples = [
'test_0.jpg',
'test_1.jpg',
'test_2.jpg',
'test_4.jpeg'
]
iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)
iface.launch(inline=False) |