Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,21 +16,21 @@ model_path = Path(r'efficientnet_b3_model.pkl')
|
|
| 16 |
learn = load_learner(model_path, cpu=True)
|
| 17 |
|
| 18 |
# Define the prediction function
|
| 19 |
-
def classify_image(image
|
| 20 |
pred, idx, probs = learn.predict(image)
|
| 21 |
-
return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(probs))}
|
| 22 |
|
| 23 |
# Set up the Gradio interface
|
| 24 |
interface = gr.Interface(
|
| 25 |
fn=classify_image,
|
| 26 |
-
inputs=gr.
|
| 27 |
-
outputs=
|
| 28 |
title="EfficientNet B3 Image Classifier",
|
| 29 |
examples= examples,
|
| 30 |
description="Upload an image to classify using the trained EfficientNet B3 model.",
|
| 31 |
-
|
| 32 |
)
|
| 33 |
|
|
|
|
| 34 |
# Launch the app
|
| 35 |
if __name__ == "__main__":
|
| 36 |
interface.launch(share=True)
|
|
|
|
| 16 |
learn = load_learner(model_path, cpu=True)
|
| 17 |
|
| 18 |
# Define the prediction function
|
| 19 |
+
def classify_image(image):
|
| 20 |
pred, idx, probs = learn.predict(image)
|
| 21 |
+
return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(probs))}
|
| 22 |
|
| 23 |
# Set up the Gradio interface
|
| 24 |
interface = gr.Interface(
|
| 25 |
fn=classify_image,
|
| 26 |
+
inputs=gr.Image(type="pil"),
|
| 27 |
+
outputs=gr.Label(num_top_classes=3),
|
| 28 |
title="EfficientNet B3 Image Classifier",
|
| 29 |
examples= examples,
|
| 30 |
description="Upload an image to classify using the trained EfficientNet B3 model.",
|
|
|
|
| 31 |
)
|
| 32 |
|
| 33 |
+
|
| 34 |
# Launch the app
|
| 35 |
if __name__ == "__main__":
|
| 36 |
interface.launch(share=True)
|