Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import base64
|
| 2 |
-
import fal_client
|
| 3 |
import gradio as gr
|
| 4 |
import io
|
| 5 |
import openai
|
|
@@ -95,13 +94,6 @@ example_images = [
|
|
| 95 |
]
|
| 96 |
|
| 97 |
|
| 98 |
-
# Function to handle AI generation progress updates
|
| 99 |
-
def on_queue_update(update):
|
| 100 |
-
if isinstance(update, fal_client.InProgress):
|
| 101 |
-
for log in update.logs:
|
| 102 |
-
print(log["message"])
|
| 103 |
-
|
| 104 |
-
|
| 105 |
# Main function to process the uploaded image
|
| 106 |
def process_image(img):
|
| 107 |
print("Starting prediction...")
|
|
@@ -147,7 +139,7 @@ def clear_outputs():
|
|
| 147 |
label_output: None,
|
| 148 |
generated_image: None,
|
| 149 |
wiki_output: None,
|
| 150 |
-
|
| 151 |
}
|
| 152 |
|
| 153 |
|
|
@@ -165,7 +157,7 @@ with gr.Blocks() as demo:
|
|
| 165 |
with gr.Column():
|
| 166 |
label_output = gr.Label(label="Classification Results")
|
| 167 |
wiki_output = gr.Textbox(label="Wikipedia Article Link", lines=1)
|
| 168 |
-
|
| 169 |
generated_image = gr.Image(label="AI Generated Interpretation")
|
| 170 |
|
| 171 |
# Add example images using local paths
|
|
@@ -174,19 +166,19 @@ with gr.Blocks() as demo:
|
|
| 174 |
inputs=input_image,
|
| 175 |
examples_per_page=6,
|
| 176 |
fn=process_image,
|
| 177 |
-
outputs=[label_output, generated_image, wiki_output,
|
| 178 |
)
|
| 179 |
|
| 180 |
input_image.change(
|
| 181 |
fn=process_image,
|
| 182 |
inputs=input_image,
|
| 183 |
-
outputs=[label_output, generated_image, wiki_output,
|
| 184 |
)
|
| 185 |
|
| 186 |
input_image.clear(
|
| 187 |
fn=clear_outputs,
|
| 188 |
inputs=[],
|
| 189 |
-
outputs=[label_output, generated_image, wiki_output,
|
| 190 |
)
|
| 191 |
|
| 192 |
# Start the application
|
|
|
|
| 1 |
import base64
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import io
|
| 4 |
import openai
|
|
|
|
| 94 |
]
|
| 95 |
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
# Main function to process the uploaded image
|
| 98 |
def process_image(img):
|
| 99 |
print("Starting prediction...")
|
|
|
|
| 139 |
label_output: None,
|
| 140 |
generated_image: None,
|
| 141 |
wiki_output: None,
|
| 142 |
+
endangerment_output: None # ← NEW
|
| 143 |
}
|
| 144 |
|
| 145 |
|
|
|
|
| 157 |
with gr.Column():
|
| 158 |
label_output = gr.Label(label="Classification Results")
|
| 159 |
wiki_output = gr.Textbox(label="Wikipedia Article Link", lines=1)
|
| 160 |
+
endangerment_output = gr.Textbox(label="Endangerment Status", lines=1) # ← NEW
|
| 161 |
generated_image = gr.Image(label="AI Generated Interpretation")
|
| 162 |
|
| 163 |
# Add example images using local paths
|
|
|
|
| 166 |
inputs=input_image,
|
| 167 |
examples_per_page=6,
|
| 168 |
fn=process_image,
|
| 169 |
+
outputs=[label_output, generated_image, wiki_output, endangerment_output]
|
| 170 |
)
|
| 171 |
|
| 172 |
input_image.change(
|
| 173 |
fn=process_image,
|
| 174 |
inputs=input_image,
|
| 175 |
+
outputs=[label_output, generated_image, wiki_output, endangerment_output]
|
| 176 |
)
|
| 177 |
|
| 178 |
input_image.clear(
|
| 179 |
fn=clear_outputs,
|
| 180 |
inputs=[],
|
| 181 |
+
outputs=[label_output, generated_image, wiki_output, endangerment_output]
|
| 182 |
)
|
| 183 |
|
| 184 |
# Start the application
|