Spaces:
Sleeping
Sleeping
Elliotlankun commited on
Commit ·
e333a2e
1
Parent(s): 6a1ea31
add main features for pet classifier
Browse files
app.py
CHANGED
|
@@ -1,7 +1,19 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
image = inputs=gr.Image(height=512,width=512)
|
| 14 |
+
label = gr.Label(num_top_classes=3)
|
| 15 |
+
|
| 16 |
+
title = "🐢烤迈克宠物分类器🐢"
|
| 17 |
+
description = "专为大飞机设计师👩🚀打造的宠物种分类器,更适合中国宝宝体质🚀🚀🚀🚀"
|
| 18 |
+
|
| 19 |
+
gr.Interface(fn=predict,inputs=image,outputs=label,title=title,description=description).launch()
|