|
__all__ = ['is_cat', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf'] |
|
|
|
|
|
from fastai.vision.all import * |
|
import gradio as gr |
|
|
|
|
|
|
|
|
|
learn = load_learner('VegetableVsMeat.pkl') |
|
|
|
|
|
categories = ('Meat', 'Vegetable') |
|
|
|
|
|
def classify_image(img): |
|
pred,idx,probs = learn.predict(img) |
|
return dict(zip(categories, map(float, probs))) |
|
|
|
|
|
image = gr.inputs.Image(shape=(192, 192)) |
|
label = gr.outputs.Label() |
|
examples = ['01b6f435-79ea-420c-89e8-edf515ea1446.jpg', '01bc3d53-ec5a-4e00-9a2d-88cb1160a50a.jpg', '01f91a06-3599-4f22-8854-056177c51fec.jpg', '3261012543_blue_apple_in_a_wicker_basket.png', '550b5661-880a-42e9-90ed-de0bea2505f0.jpg' ] |
|
|
|
|
|
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) |
|
intf.launch(inline=False) |
|
|