Update app.py
Browse files143 unmodified lines14414514614714814915015115215315415515636 unmodified lines19319419519619719819925 unmodified lines22522622722822923023123223324 unmodified lines258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291143 unmodified lines.dark .progress-text{color: white !important}#examples{max-width: 800px; margin: 0 auto; }'''is_reset = gr.State(value=False)def reset_all():return [0, 0, 0, 0, False, True]def end_reset():return Falsedef update_dimensions_on_upload(image):if image is None:36 unmodified linesrotate_deg = gr.Slider(label="Rotate Left–Right (degrees °)", minimum=-90, maximum=90, step=45, value=0)move_forward = gr.Slider(label="Move Forward → Close-Up", minimum=0, maximum=10, step=5, value=0)vertical_tilt = gr.Slider(label="Vertical Angle (Bird ↔ Worm)", minimum=-1, maximum=1, step=1, value=0)wideangle = gr.Checkbox(label="Wide-Angle Lens", value=False)with gr.Row():reset_btn = gr.Button("Reset")run_btn = gr.Button("Generate", variant="primary")25 unmodified linesreset_btn.click(fn=reset_all,inputs=None,outputs=[rotate_deg, move_forward, vertical_tilt, wideangle, is_reset],queue=False).then(fn=end_reset, inputs=None, outputs=[is_reset], queue=False)# Manual generationrun_event = run_btn.click(fn=infer_camera_edit, inputs=inputs, outputs=outputs)24 unmodified lines).then(fn=reset_all,inputs=None,outputs=[rotate_deg, move_forward, vertical_tilt, wideangle, is_reset],queue=False).then(fn=end_reset,inputs=None,outputs=[is_reset],queue=False)# Live updatesdef maybe_infer(is_reset, progress=gr.Progress(track_tqdm=True), *args):if is_reset:return gr.update(), gr.update(), gr.update()else:return infer_camera_edit(*args)control_inputs = [image, rotate_deg, move_forward,vertical_tilt, wideangle,seed, randomize_seed, true_guidance_scale, num_inference_steps, height, width, prev_output]control_inputs_with_flag = [is_reset] + control_inputsfor control in [rotate_deg, move_forward, vertical_tilt]:control.release(fn=maybe_infer, inputs=control_inputs_with_flag, outputs=outputs)wideangle.change(fn=maybe_infer, inputs=control_inputs_with_flag, outputs=outputs)run_event.then(lambda img, *_: img, inputs=[result], outputs=[prev_output])143 unmodified lines14414514614714814915015136 unmodified lines18818919019119219319425 unmodified lines22022122222322422522622722824 unmodified lines253254255256257258259260261262263264265266267268269270271272273143 unmodified lines.dark .progress-text{color: white !important}#examples{max-width: 800px; margin: 0 auto; }'''def reset_all():return [0, 0, 0, 0]def update_dimensions_on_upload(image):if image is None:36 unmodified linesrotate_deg = gr.Slider(label="Rotate Left–Right (degrees °)", minimum=-90, maximum=90, step=45, value=0)move_forward = gr.Slider(label="Move Forward → Close-Up", minimum=0, maximum=10, step=5, value=0)vertical_tilt = gr.Slider(label="Vertical Angle (Bird ↔ Worm)", minimum=-1, maximum=1, step=1, value=0)wideangle = gr.Slider(label="Wide-Angle Lens", minimum=0, maximum=1, step=1, value=0)with gr.Row():reset_btn = gr.Button("Reset")run_btn = gr.Button("Generate", variant="primary")25 unmodified linesreset_btn.click(fn=reset_all,inputs=None,outputs=[rotate_deg, move_forward, vertical_tilt, wideangle],queue=False)# Manual generationrun_event = run_btn.click(fn=infer_camera_edit, inputs=inputs, outputs=outputs)24 unmodified lines).then(fn=reset_all,inputs=None,outputs=[rotate_deg, move_forward, vertical_tilt, wideangle],queue=False)# Live updatescontrol_inputs = [image, rotate_deg, move_forward,vertical_tilt, wideangle,seed, randomize_seed, true_guidance_scale, num_inference_steps, height, width, prev_output]# All sliders use .release() to avoid triggering during resetfor control in [rotate_deg, move_forward, vertical_tilt, wideangle]:control.release(fn=infer_camera_edit, inputs=control_inputs, outputs=outputs)run_event.then(lambda img, *_: img, inputs=[result], outputs=[prev_output])
app.py+8-26