CoolFace
Apppublic

Joeythemonster/Text2Video-Zero

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app_depth.py92 linesDownload Raw Back to root
1import gradio as gr2from model import Model3import os4on_huggingspace = os.environ.get("SPACE_AUTHOR_NAME") == "PAIR"5 6 7def create_demo(model: Model):8 9    examples = [10        ["__assets__/depth_videos_depth/girl_dancing.mp4",11            "A stormtrooper, masterpiece, a high-quality, detailed, and professional photo"],12        ["__assets__/depth_videos_depth/girl_dancing.mp4",13            "Oil painting of a catwoman, masterpiece, a high-quality, detailed, and professional photo"],14        ["__assets__/depth_videos_depth/girl_dancing.mp4",15            "Oil painting of a girl dancing closed eyes, masterpiece, a high-quality, detailed, and professional photo"],16 17        ["__assets__/depth_videos_depth/woman.mp4",18            "A robot is dancing in the Sahara desert, detailed, and professional photo"],19        ["__assets__/depth_videos_depth/woman.mp4",20            "Wonder woman is dancing, a high-quality, detailed, and professional photo"],21        ["__assets__/depth_videos_depth/woman.mp4",22            "Oil painting of a girl dancing close-up, masterpiece, a high-quality, detailed, and professional photo"],23 24        ["__assets__/depth_videos_depth/man.mp4",25            "An astronaut is Dancing in space, a high-quality, detailed, and professional photo"],26        ["__assets__/depth_videos_depth/man.mp4",27            "Iron Man is dancing, a high-quality, detailed, and professional photo"],28        ["__assets__/depth_videos_depth/man.mp4",29            "Spiderman is Dancing, a high-quality, detailed, and professional photo"],30 31        ["__assets__/depth_videos_depth/halloween.mp4",32            "Beautiful blonde girl, a high-quality, detailed, and professional photo"],33        ["__assets__/depth_videos_depth/halloween.mp4",34            "Beautiful brunette girl, a high-quality, detailed, and professional photo"],35        ["__assets__/depth_videos_depth/halloween.mp4",36            "Beautiful red-haired girl, a high-quality, detailed, and professional photo"],37    ]38 39    with gr.Blocks() as demo:40        with gr.Row():41            gr.Markdown('## Text and Depth Conditional Video Generation')42        with gr.Row():43            gr.HTML(44                """45                <div style="text-align: left; auto;">46                <h2 style="font-weight: 450; font-size: 1rem; margin: 0rem">47                    Description: For performance purposes, our current preview release supports any input videos but caps output videos after 80 frames and the input videos are scaled down before processing.48                </h3>49                </div>50                """)51 52        with gr.Row():53            with gr.Column():54                input_video = gr.Video(55                    label="Input Video", source='upload', format="mp4", visible=True).style(height="auto")56            with gr.Column():57                prompt = gr.Textbox(label='Prompt')58                run_button = gr.Button(label='Run')59                with gr.Accordion('Advanced options', open=False):60                    watermark = gr.Radio(["Picsart AI Research", "Text2Video-Zero",61                                         "None"], label="Watermark", value='Picsart AI Research')62                    chunk_size = gr.Slider(63                        label="Chunk size", minimum=2, maximum=16, value=2, step=1, visible=not on_huggingspace,64                        info="Number of frames processed at once. Reduce for lower memory usage.")65                    merging_ratio = gr.Slider(66                        label="Merging ratio", minimum=0.0, maximum=0.9, step=0.1, value=0.0, visible=not on_huggingspace,67                        info="Ratio of how many tokens are merged. The higher the more compression (less memory and faster inference).")68            with gr.Column():69                result = gr.Video(label="Generated Video").style(height="auto")70 71        inputs = [72            input_video,73            prompt,74            chunk_size,75            watermark,76            merging_ratio,77        ]78 79        gr.Examples(examples=examples,80                    inputs=inputs,81                    outputs=result,82                    fn=model.process_controlnet_depth,83                    # cache_examples=on_huggingspace,84                    cache_examples=False,85                    run_on_click=False,86                    )87 88        run_button.click(fn=model.process_controlnet_depth,89                         inputs=inputs,90                         outputs=result,)91    return demo92