Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,9 @@ labels = learn.dls.vocab
|
|
| 7 |
|
| 8 |
@spaces.GPU
|
| 9 |
def predict(img):
|
|
|
|
|
|
|
|
|
|
| 10 |
pred, pred_idx, probs = learn.predict(img)
|
| 11 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 12 |
|
|
|
|
| 7 |
|
| 8 |
@spaces.GPU
|
| 9 |
def predict(img):
|
| 10 |
+
# Wrap the incoming PIL image as a fastai PILImage so the model's
|
| 11 |
+
# item/batch transforms (which turn it into a tensor) actually fire.
|
| 12 |
+
img = PILImage.create(img)
|
| 13 |
pred, pred_idx, probs = learn.predict(img)
|
| 14 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 15 |
|