broadfield-dev commited on
Commit
c09b6cf
·
verified ·
1 Parent(s): b283197

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -2
app.py CHANGED
@@ -259,8 +259,28 @@ def process_input(gif_file, max_images, size, tool, lower_bound, upper_bound, pa
259
  )
260
 
261
  return report, results, gif_path, preview, len(frames)
262
- def load_demo():
263
- return "https://huggingface.co/spaces/broadfield-dev/detect-cme/resolve/main/demo_gif.gif"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  # Gradio Blocks interface
265
  with gr.Blocks(title="Solar CME Detection") as demo:
266
  gr.Markdown("""
 
259
  )
260
 
261
  return report, results, gif_path, preview, len(frames)
262
+ def load_demo(gif_file, max_images, size, tool, lower_bound, upper_bound, param1, param2, center_tolerance, morph_iterations, min_rad, display_mode, fetched_frames_state):
263
+ """Process either uploaded GIF or fetched SDO images."""
264
+ gif_file="https://huggingface.co/spaces/broadfield-dev/detect-cme/resolve/main/demo_gif.gif"
265
+
266
+ if gif_file:
267
+ frames, error = extract_frames(gif_file.name)
268
+ if error:
269
+ return error, [], None, [], 0
270
+ else:
271
+ frames = fetched_frames_state
272
+ if not frames:
273
+ return "No fetched frames available. Please fetch images first.", [], None, [], 0
274
+
275
+ # Preview all frames
276
+ preview = [Image.fromarray(frame) for frame in frames] if frames else []
277
+
278
+ # Analyze frames
279
+ report, results, gif_path = analyze_images(
280
+ frames, lower_bound, upper_bound, param1, param2, center_tolerance, morph_iterations, min_rad, display_mode
281
+ )
282
+
283
+ return report, results, gif_path, preview, len(frames)
284
  # Gradio Blocks interface
285
  with gr.Blocks(title="Solar CME Detection") as demo:
286
  gr.Markdown("""