Spaces:
Running
Running
File size: 969 Bytes
8fae8d6 |
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("model/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_images/test_0.jpg',
'test_images/test_1.jpg',
'test_images/test_2.jpg',
'test_images/test_4.jpeg'
]
iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)
iface.launch(inline=False,share=True) |