Spaces:
Sleeping
Sleeping
File size: 1,040 Bytes
8392a30 c951ada 8392a30 12d98c8 8b64710 12d98c8 8b64710 daface4 c951ada 8b64710 3137728 ca567b7 a354d41 b7245b1 4e00c2f 5f8225b a354d41 8983eae c404dbe 878ef78 c404dbe c951ada ca06cf9 25b692d a354d41 d7dd9fa 03cd51d a354d41 |
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 33 34 35 36 37 38 39 |
import gradio as gr
from transformers import pipeline
from huggingface_hub import from_pretrained_fastai
# repo_id = "YOUR_USERNAME/YOUR_LEARNER_NAME"
repo_id = "MasleK/snails_snakes_slugs"
learn = from_pretrained_fastai(repo_id)
categories = learn.dls.vocab
def predict(image):
label, index, probs = learn.predict(image)
return dict(zip(categories, map(float,probs)))
title = "Snail, snake, slug Classifier"
description = f"""<h1> Slug, snake, snail or other<h1>
<p>A classifier trained on about 600 images. Created as a demo for Gradio and HuggingFace Spaces."""
examples = ['330px-Orange_slug.jpg', 'Green_Snakes.jpg', 'Helix_pomatia_002.JPG', 'baum-jung.jpg']
interpretation='default'
enable_queue=True
gr.Interface(
predict,
inputs=gr.components.Image(label="candidate", type="filepath"),
outputs=gr.components.Label(num_top_classes=4),
title=title,
examples=examples,
description=description,
# interpretation=interpretation,
# enable_queue=enable_queue
).launch()
|