Commit
·
1fbfeee
1
Parent(s):
1928ca2
Update app.py
Browse files
app.py
CHANGED
@@ -47,8 +47,10 @@ preprocess = transforms.Compose([
|
|
47 |
])
|
48 |
|
49 |
def classify_image(image, model_name):
|
50 |
-
|
|
|
51 |
|
|
|
52 |
image = Image.fromarray(image)
|
53 |
input_image = preprocess(image).unsqueeze(0).to(device)
|
54 |
|
@@ -61,7 +63,7 @@ def classify_image(image, model_name):
|
|
61 |
|
62 |
# Gradio interface
|
63 |
image_input = gr.Image(image_mode="RGB")
|
64 |
-
model_choice = gr.
|
65 |
output_text = gr.Textbox()
|
66 |
|
67 |
gr.Interface(fn=classify_image, inputs=[image_input, model_choice], outputs=[output_text],
|
|
|
47 |
])
|
48 |
|
49 |
def classify_image(image, model_name):
|
50 |
+
if image is None:
|
51 |
+
return "Please upload an image."
|
52 |
|
53 |
+
model = load_model(model_name)
|
54 |
image = Image.fromarray(image)
|
55 |
input_image = preprocess(image).unsqueeze(0).to(device)
|
56 |
|
|
|
63 |
|
64 |
# Gradio interface
|
65 |
image_input = gr.Image(image_mode="RGB")
|
66 |
+
model_choice = gr.Dropdown(choices=list(model_options.keys()), label="Choose Model", value="ResNet-18")
|
67 |
output_text = gr.Textbox()
|
68 |
|
69 |
gr.Interface(fn=classify_image, inputs=[image_input, model_choice], outputs=[output_text],
|