Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- app.py +19 -0
- beagle.jpeg +0 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
import gradio as gr
|
4 |
+
from fastai.vision.all import *
|
5 |
+
import skimage
|
6 |
+
|
7 |
+
learn = load_learner('fast-ai/export.pkl')
|
8 |
+
|
9 |
+
labels = learn.dls.vocab
|
10 |
+
def predict(img):
|
11 |
+
img = PILImage.create(img)
|
12 |
+
pred,pred_idx,probs = learn.predict(img)
|
13 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
14 |
+
|
15 |
+
# Create and launch the Gradio interface
|
16 |
+
title = "Pet Breed Classifier"
|
17 |
+
examples = ['fast-ai/OxfordPetAI/beagle.jpeg']
|
18 |
+
description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
19 |
+
gr.Interface(fn=predict, inputs="image", outputs="label", title=title, description=description, examples=examples).launch(share=True)
|
beagle.jpeg
ADDED
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|