Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -245,12 +245,14 @@ def process_input(gif_file, max_images, size, tool, lower_bound, upper_bound, pa
|
|
| 245 |
"""Process either uploaded GIF or fetched SDO images."""
|
| 246 |
if gif_file:
|
| 247 |
frames, error = extract_frames(gif_file.name)
|
|
|
|
| 248 |
if error:
|
| 249 |
-
return error, [], None, [],
|
| 250 |
else:
|
| 251 |
frames = fetched_frames_state
|
|
|
|
| 252 |
if not frames:
|
| 253 |
-
return "No fetched frames available. Please fetch images first.", [], None, [],
|
| 254 |
|
| 255 |
# Preview all frames
|
| 256 |
preview = [Image.fromarray(frame) for frame in frames] if frames else []
|
|
@@ -260,46 +262,23 @@ def process_input(gif_file, max_images, size, tool, lower_bound, upper_bound, pa
|
|
| 260 |
frames, lower_bound, upper_bound, param1, param2, center_tolerance, morph_iterations, min_rad, display_mode, scale_to_512
|
| 261 |
)
|
| 262 |
|
| 263 |
-
return report, results, gif_path, preview,
|
| 264 |
-
|
| 265 |
-
def load_demo_2(gif_file, max_images, size, tool, lower_bound, upper_bound, param1, param2, center_tolerance, morph_iterations, min_rad, display_mode, fetched_frames_state):
|
| 266 |
-
gif_file="./demo_gif.gif"
|
| 267 |
-
if gif_file:
|
| 268 |
-
frames, error = extract_frames(gif_file)
|
| 269 |
-
if error:
|
| 270 |
-
return error, [], None, [], 0
|
| 271 |
-
else:
|
| 272 |
-
frames = fetched_frames_state
|
| 273 |
-
if not frames:
|
| 274 |
-
return "No fetched frames available. Please fetch images first.", [], None, [], 0
|
| 275 |
-
|
| 276 |
-
# Preview all frames
|
| 277 |
-
preview = [Image.fromarray(frame) for frame in frames] if frames else []
|
| 278 |
-
|
| 279 |
-
# Analyze frames
|
| 280 |
-
report, results, gif_path = analyze_images(
|
| 281 |
-
frames, lower_bound, upper_bound, param1, param2, center_tolerance, morph_iterations, min_rad, display_mode
|
| 282 |
-
)
|
| 283 |
-
|
| 284 |
-
return report, results, gif_path, preview, len(frames)
|
| 285 |
|
| 286 |
def load_demo():
|
| 287 |
-
|
| 288 |
-
|
|
|
|
| 289 |
frames, error = extract_frames(gif_file)
|
|
|
|
| 290 |
if error:
|
| 291 |
-
return error, [], None,
|
| 292 |
else:
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
return "No fetched frames available. Please fetch images first.", [], None, [], 0
|
| 296 |
preview = [Image.fromarray(frame) for frame in frames] if frames else []
|
| 297 |
-
|
| 298 |
-
message="Demo Loaded"
|
| 299 |
return message, preview, frames, total_images
|
| 300 |
|
| 301 |
-
|
| 302 |
-
# Gradio Blocks interface
|
| 303 |
# Gradio Blocks interface
|
| 304 |
with gr.Blocks(title="Solar CME Detection") as demo:
|
| 305 |
gr.Markdown("""
|
|
|
|
| 245 |
"""Process either uploaded GIF or fetched SDO images."""
|
| 246 |
if gif_file:
|
| 247 |
frames, error = extract_frames(gif_file.name)
|
| 248 |
+
total_images = 0 # No total images when using uploaded GIF
|
| 249 |
if error:
|
| 250 |
+
return error, [], None, [], total_images, None
|
| 251 |
else:
|
| 252 |
frames = fetched_frames_state
|
| 253 |
+
_, _, total_images = fetch_sdo_images(max_images, size, tool) # Get total_images
|
| 254 |
if not frames:
|
| 255 |
+
return "No fetched frames available. Please fetch images first.", [], None, [], total_images, None
|
| 256 |
|
| 257 |
# Preview all frames
|
| 258 |
preview = [Image.fromarray(frame) for frame in frames] if frames else []
|
|
|
|
| 262 |
frames, lower_bound, upper_bound, param1, param2, center_tolerance, morph_iterations, min_rad, display_mode, scale_to_512
|
| 263 |
)
|
| 264 |
|
| 265 |
+
return report, results, gif_path, preview, total_images, gif_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
|
| 267 |
def load_demo():
|
| 268 |
+
"""Load demo GIF for analysis."""
|
| 269 |
+
gif_file = "./demo_gif.gif"
|
| 270 |
+
if os.path.exists(gif_file):
|
| 271 |
frames, error = extract_frames(gif_file)
|
| 272 |
+
total_images = 0 # Demo GIF, so no directory total
|
| 273 |
if error:
|
| 274 |
+
return error, [], None, total_images
|
| 275 |
else:
|
| 276 |
+
return "Demo GIF not found.", [], None, 0
|
| 277 |
+
|
|
|
|
| 278 |
preview = [Image.fromarray(frame) for frame in frames] if frames else []
|
| 279 |
+
message = "Demo Loaded"
|
|
|
|
| 280 |
return message, preview, frames, total_images
|
| 281 |
|
|
|
|
|
|
|
| 282 |
# Gradio Blocks interface
|
| 283 |
with gr.Blocks(title="Solar CME Detection") as demo:
|
| 284 |
gr.Markdown("""
|