Spaces:
Sleeping
Sleeping
fixed bug for true/false classifier
Browse files
app.py
CHANGED
@@ -2,13 +2,19 @@ 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
|
|
|
|
|
|
|
12 |
|
13 |
title = "Dog Cat Classifier"
|
14 |
description = "A dog cat classifier. Created as a demo for Gradio and HuggingFace Spaces."
|
|
|
2 |
from fastai.vision.all import *
|
3 |
import skimage
|
4 |
|
5 |
+
# create function to distinguish dogs from cats
|
6 |
+
def label_func(f): return f[0].isupper()
|
7 |
+
|
8 |
learn = load_learner('export.pkl')
|
9 |
|
10 |
+
# labels = learn.dls.vocab
|
11 |
def predict(img):
|
12 |
img = PILImage.create(img)
|
13 |
pred,pred_idx,probs = learn.predict(img)
|
14 |
+
return pred
|
15 |
+
# return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
16 |
+
|
17 |
+
# ('False', TensorBase(0), TensorBase([9.9999e-01, 7.5253e-06]))
|
18 |
|
19 |
title = "Dog Cat Classifier"
|
20 |
description = "A dog cat classifier. Created as a demo for Gradio and HuggingFace Spaces."
|