in experiments/veo-app/pages/veo.py [0:0]
def veo_content(app_state: me.state):
"""Veo 2 Mesop Page"""
state = me.state(PageState)
with page_scaffold(): # pylint: disable=not-context-manager
with page_frame(): # pylint: disable=not-context-manager
header("Veo 2", "movie")
# tricolumn
with me.box(
style=me.Style(
display="flex",
flex_direction="row",
gap=10,
height=250,
)
):
# Controls
with me.box(
style=me.Style(
# flex_basis="450px",
flex_basis="max(480px, calc(60% - 48px))",
display="flex",
flex_direction="column",
align_items="stretch",
justify_content="space-between",
gap=10,
)
):
subtle_veo_input()
# me.box(style=me.Style(height=12))
# me.text("no video generated")
with me.box(
style=me.Style(display="flex", flex_basis="row", gap=5)
):
me.select(
label="aspect",
appearance="outline",
options=[
me.SelectOption(label="16:9 widescreen", value="16:9"),
me.SelectOption(label="9:16 portrait", value="9:16"),
],
value=state.aspect_ratio,
on_selection_change=on_selection_change_aspect,
)
me.select(
label="length",
options=[
me.SelectOption(label="5 seconds", value="5"),
me.SelectOption(label="6 seconds", value="6"),
me.SelectOption(label="7 seconds", value="7"),
me.SelectOption(label="8 seconds", value="8"),
],
appearance="outline",
style=me.Style(),
value=f"{state.video_length}",
on_selection_change=on_selection_change_length,
)
me.checkbox(
label="auto-enhance prompt",
checked=state.auto_enhance_prompt,
on_change=on_change_auto_enhance_prompt,
)
# Uploaded image
with me.box(style=_BOX_STYLE_CENTER_DISTRIBUTED):
me.text("Reference Image (optional)")
if state.reference_image_uri:
output_url = state.reference_image_uri
# output_url = f"https://storage.mtls.cloud.google.com/{state.reference_image_uri}"
# output_url = "https://storage.mtls.cloud.google.com/ghchinoy-genai-sa-assets-flat/edits/image (30).png"
print(f"displaying {output_url}")
me.image(
src=output_url,
style=me.Style(
height=150,
border_radius=12,
),
key=str(state.reference_image_file_key),
)
else:
me.image(src=None, style=me.Style(height=200))
with me.box(
style=me.Style(display="flex", flex_direction="row", gap=5)
):
# me.button(label="Upload", type="flat", disabled=True)
me.uploader(
label="Upload",
accepted_file_types=["image/jpeg", "image/png"],
on_upload=on_click_upload,
type="flat",
color="primary",
style=me.Style(font_weight="bold"),
)
me.button(
label="Clear", on_click=on_click_clear_reference_image
)
me.box(style=me.Style(height=30))
# Generated video
with me.box(style=_BOX_STYLE_CENTER_DISTRIBUTED):
me.text("Generated Video")
me.box(style=me.Style(height=8))
with me.box(style=me.Style(height="100%")):
if state.is_loading:
me.progress_spinner()
elif state.result_video:
video_url = state.result_video.replace(
"gs://",
"https://storage.mtls.cloud.google.com/",
)
print(f"video_url: {video_url}")
me.video(src=video_url, style=me.Style(border_radius=6))
me.text(state.timing)
with dialog(is_open=state.show_error_dialog): # pylint: disable=not-context-manager
# Content within the dialog box
me.text(
"Generation Error",
type="headline-6",
style=me.Style(color=me.theme_var("error")),
)
me.text(state.error_message, style=me.Style(margin=me.Margin(top=16)))
# Use the dialog_actions component for the button
with dialog_actions(): # pylint: disable=not-context-manager
me.button("Close", on_click=on_close_error_dialog, type="flat")