Phauglin commited on
Commit
d708a87
·
verified ·
1 Parent(s): 7e7188e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -33
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
- with gr.Blocks() as demo:
152
- # Input section
153
- with gr.Row():
154
- input_image = gr.Image(height=230, width=230, label="Upload Image for Classification", type="pil")
155
-
156
- # Output section
157
- with gr.Row():
158
- with gr.Column():
159
- label_output = gr.Label(label="Classification Results")
160
- wiki_output = gr.Textbox(label="Wikipedia Article Link", lines=1)
161
- endangerment_output = gr.Textbox(label="Endangerment Status", lines=1) # ← NEW
162
- generated_image = gr.Image(label="AI Generated Interpretation")
163
-
164
- # Add example images using local paths
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)