| | from fastai.vision.all import * |
| | import gradio as gr |
| |
|
| | |
| |
|
| | |
| | learn = load_learner('persimmon_model.pkl') |
| |
|
| | |
| | categories = ('persimmon', 'tomato') |
| |
|
| | 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 = ['persimmon.jpg', 'tomato.jpg', 'persimmontree.jpg', |
| | 'tomatoplant.jpg', 'cat.jpg', 'tomatoplant2.jpg'] |
| |
|
| | intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, |
| | title="Persimmon or Tomato?", description="Trained on only persimmon and tomato images auto-retrieved from a DDG search using resnet18. Provide an image or select from one below.") |
| | intf.launch(inline=False) |
| |
|
| | |
| | |
| |
|
| | |
| | |
| |
|