File size: 735 Bytes
a78659f ad1c4a7 f0403f0 a78659f 81d7092 a78659f 81d7092 a78659f f2f571a a78659f ccd7fce a694cf2 a78659f 74a05b7 f0403f0 a78659f |
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 |
__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)
|