|
|
|
__all__ = ["label_func", "learner", "classify_image", "categories", "image", "label", "examples", "demo"] |
|
|
|
from fastai.vision.all import * |
|
import gradio as gr |
|
from huggingface_hub import from_pretrained_fastai |
|
|
|
def label_func(f): return f[0] == 'p' |
|
def acc_camvid(*_): pass |
|
def get_y(*_): pass |
|
|
|
learner = from_pretrained_fastai("reshane/PoisonIvy") |
|
|
|
categories = ('Not Poison Ivy', 'Poison Ivy') |
|
|
|
|
|
def classify_image(img): |
|
pred,idx,probs = learner.predict(img) |
|
return dict(zip(categories, map(float,probs))) |
|
|
|
image = gr.Image(type="filepath", width=192, height=192) |
|
label = gr.Label() |
|
examples = ["pepe.jpg"] |
|
|
|
|
|
|
|
demo = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) |
|
demo.launch(inline=False) |
|
|
|
|