Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,9 @@ labels = learn.dls.vocab
|
|
10 |
|
11 |
# Prediction function
|
12 |
def predict(img):
|
|
|
13 |
img = PILImage.create(img)
|
|
|
14 |
pred, pred_idx, probs = learn.predict(img)
|
15 |
prediction = str(pred)
|
16 |
return prediction
|
@@ -33,8 +35,8 @@ enable_queue = True
|
|
33 |
# Update the interface components
|
34 |
gr.Interface(
|
35 |
fn=predict,
|
36 |
-
inputs=gr.Image(
|
37 |
-
outputs=gr.Label(num_top_classes=3),
|
38 |
title=title,
|
39 |
description=description,
|
40 |
article=article,
|
|
|
10 |
|
11 |
# Prediction function
|
12 |
def predict(img):
|
13 |
+
# Resize the image inside the function (if required)
|
14 |
img = PILImage.create(img)
|
15 |
+
img = img.resize((512, 512)) # Resize image to (512, 512)
|
16 |
pred, pred_idx, probs = learn.predict(img)
|
17 |
prediction = str(pred)
|
18 |
return prediction
|
|
|
35 |
# Update the interface components
|
36 |
gr.Interface(
|
37 |
fn=predict,
|
38 |
+
inputs=gr.Image(type="pil"), # Use the 'type' argument instead of 'shape'
|
39 |
+
outputs=gr.Label(num_top_classes=3),
|
40 |
title=title,
|
41 |
description=description,
|
42 |
article=article,
|