fpramunno commited on
Commit
cf7ac47
1 Parent(s): ff34208

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -8
app.py CHANGED
@@ -60,12 +60,30 @@ def generate_image(seed_image):
60
  return inp, v
61
 
62
  # Create Gradio interface
63
- iface = gr.Interface(
64
- fn=generate_image,
65
- inputs="file",
66
- outputs="image",
67
- title="Magnetogram-to-Magnetogram: Generative Forecasting of Solar Evolution",
68
- description="Upload a LoS magnetogram and predict how it is going to be in 24 hours."
69
- )
 
 
 
 
70
 
71
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  return inp, v
61
 
62
  # Create Gradio interface
63
+ with gr.Blocks() as demo:
64
+ gr.Markdown(DESCRIPTION)
65
+ with gr.Row():
66
+ input_image = gr.File(label='Input Image')
67
+ output_image1 = gr.Image(label='Input LoS Magnetogram', type='pil', interactive=False)
68
+ output_image2 = gr.Image(label='Predicted LoS Magnetogram in 24 hours', type='pil', interactive=False)
69
+ # Buttons are placed in a nested Row inside the main Row to align them directly under the image
70
+ with gr.Row():
71
+ clear_button = gr.Button('Clear')
72
+ process_button = gr.Button('Generate')
73
+
74
 
75
+ # Binding the process button to the function
76
+ process_button.click(
77
+ fn=generate_image,
78
+ inputs=input_image,
79
+ outputs=[output_image1, output_image2]
80
+ )
81
+
82
+ # Clear button to reset the input image
83
+ clear_button.click(
84
+ fn=lambda: None, # Clears the input
85
+ inputs=None,
86
+ outputs=input_image
87
+ )
88
+
89
+ demo.launch()