CoolFace
Apppublic

Joeythemonster/Text2Video-Zero

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app_canny.py79 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__/canny_videos_edge/butterfly.mp4",11            "white butterfly, a high-quality, detailed, and professional photo"],12        ["__assets__/canny_videos_edge/deer.mp4",13            "oil painting of a deer, a high-quality, detailed, and professional photo"],14        ["__assets__/canny_videos_edge/fox.mp4",15            "wild red fox is walking on the grass, a high-quality, detailed, and professional photo"],16        ["__assets__/canny_videos_edge/girl_dancing.mp4",17            "oil painting of a girl dancing close-up, masterpiece, a high-quality, detailed, and professional photo"],18        ["__assets__/canny_videos_edge/girl_turning.mp4",19            "oil painting of a beautiful girl, a high-quality, detailed, and professional photo"],20        ["__assets__/canny_videos_edge/halloween.mp4",21            "beautiful girl halloween style, a high-quality, detailed, and professional photo"],22        ["__assets__/canny_videos_edge/santa.mp4",23            "a santa claus, a high-quality, detailed, and professional photo"],24    ]25 26    with gr.Blocks() as demo:27        with gr.Row():28            gr.Markdown('## Text and Canny-Edge Conditional Video Generation')29        with gr.Row():30            gr.HTML(31                """32                <div style="text-align: left; auto;">33                <h2 style="font-weight: 450; font-size: 1rem; margin: 0rem">34                    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.35                </h3>36                </div>37                """)38 39        with gr.Row():40            with gr.Column():41                input_video = gr.Video(42                    label="Input Video", source='upload', format="mp4", visible=True).style(height="auto")43            with gr.Column():44                prompt = gr.Textbox(label='Prompt')45                run_button = gr.Button(label='Run')46                with gr.Accordion('Advanced options', open=False):47                    watermark = gr.Radio(["Picsart AI Research", "Text2Video-Zero",48                                         "None"], label="Watermark", value='Picsart AI Research')49                    chunk_size = gr.Slider(50                        label="Chunk size", minimum=2, maximum=16, value=2, step=1, visible=not on_huggingspace,51                        info="Number of frames processed at once. Reduce for lower memory usage.")52                    merging_ratio = gr.Slider(53                        label="Merging ratio", minimum=0.0, maximum=0.9, step=0.1, value=0.0, visible=not on_huggingspace,54                        info="Ratio of how many tokens are merged. The higher the more compression (less memory and faster inference).")55            with gr.Column():56                result = gr.Video(label="Generated Video").style(height="auto")57 58        inputs = [59            input_video,60            prompt,61            chunk_size,62            watermark,63            merging_ratio,64        ]65 66        gr.Examples(examples=examples,67                    inputs=inputs,68                    outputs=result,69                    fn=model.process_controlnet_canny,70                    # cache_examples=on_huggingspace,71                    cache_examples=False,72                    run_on_click=False,73                    )74 75        run_button.click(fn=model.process_controlnet_canny,76                         inputs=inputs,77                         outputs=result,)78    return demo79