Spaces:
Running on Zero
Running on Zero
Update app.py
#46
by linoyts HF Staff - opened
app.py
CHANGED
|
@@ -192,8 +192,6 @@ def create_video_between_images(
|
|
| 192 |
|
| 193 |
|
| 194 |
# --- 3D Camera Control Component for 2509 ---
|
| 195 |
-
# Using gr.HTML directly with templates (Gradio 6 style)
|
| 196 |
-
|
| 197 |
CAMERA_3D_HTML_TEMPLATE = """
|
| 198 |
<div id="camera-control-wrapper" style="width: 100%; height: 400px; position: relative; background: #1a1a1a; border-radius: 12px; overflow: hidden;">
|
| 199 |
<div id="prompt-overlay" style="position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.8); padding: 8px 16px; border-radius: 8px; font-family: monospace; font-size: 11px; color: #00ff88; white-space: nowrap; z-index: 10; max-width: 90%; overflow: hidden; text-overflow: ellipsis;"></div>
|
|
@@ -844,14 +842,9 @@ with gr.Blocks() as demo:
|
|
| 844 |
).then(fn=update_3d_image, inputs=[image], outputs=[camera_3d])
|
| 845 |
|
| 846 |
image.clear(fn=lambda: gr.update(imageUrl=None), outputs=[camera_3d])
|
| 847 |
-
|
| 848 |
-
# Live updates on slider release
|
| 849 |
-
for control in [rotate_deg, move_forward, vertical_tilt]:
|
| 850 |
-
control.release(fn=maybe_infer, inputs=control_inputs_with_flag, outputs=outputs + [create_video_button])
|
| 851 |
-
wideangle.input(fn=maybe_infer, inputs=control_inputs_with_flag, outputs=outputs + [create_video_button])
|
| 852 |
-
|
| 853 |
run_event.then(lambda img, *_: img, inputs=[result], outputs=[prev_output])
|
| 854 |
-
|
| 855 |
|
| 856 |
gr.Examples(
|
| 857 |
examples=[
|
|
@@ -869,21 +862,6 @@ with gr.Blocks() as demo:
|
|
| 869 |
elem_id="examples"
|
| 870 |
)
|
| 871 |
|
| 872 |
-
# Sync 3D component when sliders change (covers example loading)
|
| 873 |
-
def sync_3d_on_slider_change(img, rot, fwd, tilt, wide):
|
| 874 |
-
camera_value = {"rotate_deg": rot, "move_forward": fwd, "vertical_tilt": tilt, "wideangle": wide}
|
| 875 |
-
if img is not None:
|
| 876 |
-
buffered = BytesIO()
|
| 877 |
-
img.save(buffered, format="PNG")
|
| 878 |
-
img_str = base64.b64encode(buffered.getvalue()).decode()
|
| 879 |
-
data_url = f"data:image/png;base64,{img_str}"
|
| 880 |
-
return gr.update(value=camera_value, imageUrl=data_url)
|
| 881 |
-
return gr.update(value=camera_value)
|
| 882 |
-
|
| 883 |
-
# When any slider value changes (including from examples), sync the 3D component
|
| 884 |
-
for slider in [rotate_deg, move_forward, vertical_tilt]:
|
| 885 |
-
slider.change(fn=sync_3d_on_slider_change, inputs=[image, rotate_deg, move_forward, vertical_tilt, wideangle], outputs=[camera_3d])
|
| 886 |
-
|
| 887 |
gr.api(infer_camera_edit, api_name="infer_edit_camera_angles")
|
| 888 |
gr.api(create_video_between_images, api_name="create_video_between_images")
|
| 889 |
|
|
|
|
| 192 |
|
| 193 |
|
| 194 |
# --- 3D Camera Control Component for 2509 ---
|
|
|
|
|
|
|
| 195 |
CAMERA_3D_HTML_TEMPLATE = """
|
| 196 |
<div id="camera-control-wrapper" style="width: 100%; height: 400px; position: relative; background: #1a1a1a; border-radius: 12px; overflow: hidden;">
|
| 197 |
<div id="prompt-overlay" style="position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.8); padding: 8px 16px; border-radius: 8px; font-family: monospace; font-size: 11px; color: #00ff88; white-space: nowrap; z-index: 10; max-width: 90%; overflow: hidden; text-overflow: ellipsis;"></div>
|
|
|
|
| 842 |
).then(fn=update_3d_image, inputs=[image], outputs=[camera_3d])
|
| 843 |
|
| 844 |
image.clear(fn=lambda: gr.update(imageUrl=None), outputs=[camera_3d])
|
| 845 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 846 |
run_event.then(lambda img, *_: img, inputs=[result], outputs=[prev_output])
|
| 847 |
+
|
| 848 |
|
| 849 |
gr.Examples(
|
| 850 |
examples=[
|
|
|
|
| 862 |
elem_id="examples"
|
| 863 |
)
|
| 864 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 865 |
gr.api(infer_camera_edit, api_name="infer_edit_camera_angles")
|
| 866 |
gr.api(create_video_between_images, api_name="create_video_between_images")
|
| 867 |
|