Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,13 +8,19 @@ def load_model():
|
|
8 |
return learn
|
9 |
|
10 |
learn = load_model()
|
|
|
11 |
# Define prediction function
|
12 |
def predict_image(img):
|
13 |
pred, pred_idx, probs = learn.predict(img)
|
14 |
return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(learn.dls.vocab))}
|
15 |
|
16 |
-
#
|
17 |
-
gr.Interface(fn=predict_image,
|
|
|
|
|
|
|
|
|
18 |
|
|
|
19 |
if __name__ == "__main__":
|
20 |
interface.launch()
|
|
|
8 |
return learn
|
9 |
|
10 |
learn = load_model()
|
11 |
+
|
12 |
# Define prediction function
|
13 |
def predict_image(img):
|
14 |
pred, pred_idx, probs = learn.predict(img)
|
15 |
return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(learn.dls.vocab))}
|
16 |
|
17 |
+
# Ensure this matches the function name used in the Interface
|
18 |
+
interface = gr.Interface(fn=predict_image,
|
19 |
+
inputs=gr.Image(type="pil"), # Corrected to use gr.Image
|
20 |
+
outputs=gr.Label(num_top_classes=3),
|
21 |
+
title="Image Classifier",
|
22 |
+
description="Upload an image to classify.")
|
23 |
|
24 |
+
# Use the defined 'interface' variable to launch the Gradio interface
|
25 |
if __name__ == "__main__":
|
26 |
interface.launch()
|