Spaces:
Build error
Build error
upload of the data
Browse files- app.py +28 -0
- bengal.jpg +0 -0
- export.pkl +3 -0
- requirements.rtf +11 -0
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
+
|
5 |
+
learn = load_learner('export.pkl')
|
6 |
+
|
7 |
+
labels = learn.dls.vocab
|
8 |
+
def predict(img):
|
9 |
+
img = PILImage.create(img)
|
10 |
+
pred,pred_idx,probs = learn.predict(img)
|
11 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
12 |
+
|
13 |
+
title = "Pet Breed Classifier"
|
14 |
+
description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
15 |
+
article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
|
16 |
+
examples = ['bengal.jpg']
|
17 |
+
interpretation='default'
|
18 |
+
enable_queue=True
|
19 |
+
|
20 |
+
gr.Interface(
|
21 |
+
fn=predict,
|
22 |
+
inputs=gr.inputs.Image(shape=(512, 512)),
|
23 |
+
outputs=gr.outputs.Label(num_top_classes=3),
|
24 |
+
title=title,description=description,article=article,
|
25 |
+
examples=examples,
|
26 |
+
interpretation=interpretation,
|
27 |
+
enable_queue=enable_queue
|
28 |
+
).launch()
|
bengal.jpg
ADDED
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:795e213c4511b32a9eb9e43811d8ffb35233d93802a8fe7692ab83f35f1de8b3
|
3 |
+
size 103050069
|
requirements.rtf
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{\rtf1\ansi\ansicpg1252\cocoartf2638
|
2 |
+
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 Menlo-Regular;}
|
3 |
+
{\colortbl;\red255\green255\blue255;\red27\green31\blue34;\red234\green233\blue255;}
|
4 |
+
{\*\expandedcolortbl;;\cssrgb\c14118\c16078\c18039;\cssrgb\c93333\c93333\c100000;}
|
5 |
+
\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0
|
6 |
+
\deftab720
|
7 |
+
\pard\pardeftab720\partightenfactor0
|
8 |
+
|
9 |
+
\f0\fs24 \cf2 \cb3 \expnd0\expndtw0\kerning0
|
10 |
+
fastai\
|
11 |
+
scikit-image}
|