ABAAS1 commited on
Commit
b5a5e6c
·
verified ·
1 Parent(s): 18ab795

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -0
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