Update app.py
Browse files
app.py
CHANGED
|
@@ -148,39 +148,20 @@ def clear_outputs():
|
|
| 148 |
learn = load_learner('resnet50_30_categories.pkl')
|
| 149 |
|
| 150 |
# Create the web interface
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
gr.Examples(
|
| 166 |
-
examples=example_images,
|
| 167 |
-
inputs=input_image,
|
| 168 |
-
examples_per_page=6,
|
| 169 |
-
fn=None,
|
| 170 |
-
outputs=None
|
| 171 |
-
)
|
| 172 |
-
|
| 173 |
-
input_image.change(
|
| 174 |
-
fn=lambda img: process_image(img, generate_image=True),
|
| 175 |
-
inputs=input_image,
|
| 176 |
-
outputs=[label_output, generated_image, wiki_output, endangerment_output]
|
| 177 |
-
)
|
| 178 |
-
|
| 179 |
-
input_image.clear(
|
| 180 |
-
fn=clear_outputs,
|
| 181 |
-
inputs=[],
|
| 182 |
-
outputs=[label_output, generated_image, wiki_output, endangerment_output]
|
| 183 |
-
)
|
| 184 |
|
| 185 |
# Start the application
|
| 186 |
demo.launch(inline=False)
|
|
|
|
| 148 |
learn = load_learner('resnet50_30_categories.pkl')
|
| 149 |
|
| 150 |
# Create the web interface
|
| 151 |
+
demo = gr.Interface(
|
| 152 |
+
fn=process_image,
|
| 153 |
+
inputs=gr.Image(height=230, width=230, label="Upload Image for Classification", type="pil"),
|
| 154 |
+
outputs=[
|
| 155 |
+
gr.Label(label="Classification Results"),
|
| 156 |
+
gr.Image(label="AI Generated Interpretation"),
|
| 157 |
+
gr.Textbox(label="Wikipedia Article Link", lines=1),
|
| 158 |
+
gr.Textbox(label="Endangerment Status", lines=1)
|
| 159 |
+
],
|
| 160 |
+
examples=example_images,
|
| 161 |
+
examples_per_page=6,
|
| 162 |
+
title="California Native Flower Classifier",
|
| 163 |
+
description="Upload an image of a California native flower to classify it and see an AI-generated interpretation."
|
| 164 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
# Start the application
|
| 167 |
demo.launch(inline=False)
|