Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,10 +6,12 @@ from fastai.vision.all import PILImage
|
|
6 |
learn = load_learner('model.pkl')
|
7 |
|
8 |
labels = learn.dls.vocab
|
|
|
9 |
def predict(img):
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
13 |
|
14 |
examples = ['image.jpg']
|
15 |
|
|
|
6 |
learn = load_learner('model.pkl')
|
7 |
|
8 |
labels = learn.dls.vocab
|
9 |
+
|
10 |
def predict(img):
|
11 |
+
img = PILImage.create(img)
|
12 |
+
img = img.resize((512, 512))
|
13 |
+
pred,pred_idx,probs = learn.predict(img)
|
14 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
15 |
|
16 |
examples = ['image.jpg']
|
17 |
|