| 199 | return generation_method, length_slider, overlap_video_length, partial_video_length |
| 200 | |
| 201 | def create_generation_method(source_method_options, prompt_textbox, support_end_image=True): |
| 202 | source_method = gr.Radio( |
| 203 | source_method_options, |
| 204 | value="Text to Video (文本到视频)", |
| 205 | show_label=False, |
| 206 | ) |
| 207 | with gr.Column(visible = False) as image_to_video_col: |
| 208 | start_image = gr.Image( |
| 209 | label="The image at the beginning of the video (图片到视频的开始图片)", show_label=True, |
| 210 | elem_id="i2v_start", sources="upload", type="filepath", |
| 211 | ) |
| 212 | |
| 213 | template_gallery_path = ["asset/1.png", "asset/2.png", "asset/3.png", "asset/4.png", "asset/5.png"] |
| 214 | def select_template(evt: gr.SelectData): |
| 215 | text = { |
| 216 | "asset/1.png": "A brown dog is shaking its head and sitting on a light colored sofa in a comfortable room. Behind the dog, there is a framed painting on the shelf surrounded by pink flowers. The soft and warm lighting in the room creates a comfortable atmosphere.", |
| 217 | "asset/2.png": "A sailboat navigates through moderately rough seas, with waves and ocean spray visible. The sailboat features a white hull and sails, accompanied by an orange sail catching the wind. The sky above shows dramatic, cloudy formations with a sunset or sunrise backdrop, casting warm colors across the scene. The water reflects the golden light, enhancing the visual contrast between the dark ocean and the bright horizon. The camera captures the scene with a dynamic and immersive angle, showcasing the movement of the boat and the energy of the ocean.", |
| 218 | "asset/3.png": "A stunningly beautiful woman with flowing long hair stands gracefully, her elegant dress rippling and billowing in the gentle wind. Petals falling off. Her serene expression and the natural movement of her attire create an enchanting and captivating scene, full of ethereal charm.", |
| 219 | "asset/4.png": "An astronaut, clad in a full space suit with a helmet, plays an electric guitar while floating in a cosmic environment filled with glowing particles and rocky textures. The scene is illuminated by a warm light source, creating dramatic shadows and contrasts. The background features a complex geometry, similar to a space station or an alien landscape, indicating a futuristic or otherworldly setting.", |
| 220 | "asset/5.png": "Fireworks light up the evening sky over a sprawling cityscape with gothic-style buildings featuring pointed towers and clock faces. The city is lit by both artificial lights from the buildings and the colorful bursts of the fireworks. The scene is viewed from an elevated angle, showcasing a vibrant urban environment set against a backdrop of a dramatic, partially cloudy sky at dusk.", |
| 221 | }[template_gallery_path[evt.index]] |
| 222 | return template_gallery_path[evt.index], text |
| 223 | |
| 224 | template_gallery = gr.Gallery( |
| 225 | template_gallery_path, |
| 226 | columns=5, rows=1, |
| 227 | height=140, |
| 228 | allow_preview=False, |
| 229 | container=False, |
| 230 | label="Template Examples", |
| 231 | ) |
| 232 | template_gallery.select(select_template, None, [start_image, prompt_textbox]) |
| 233 | |
| 234 | with gr.Accordion("The image at the ending of the video (图片到视频的结束图片[非必需, Optional])", open=False, visible=support_end_image): |
| 235 | end_image = gr.Image(label="The image at the ending of the video (图片到视频的结束图片[非必需, Optional])", show_label=False, elem_id="i2v_end", sources="upload", type="filepath") |
| 236 | |
| 237 | with gr.Column(visible = False) as video_to_video_col: |
| 238 | with gr.Row(): |
| 239 | validation_video = gr.Video( |
| 240 | label="The video to convert (视频转视频的参考视频)", show_label=True, |
| 241 | elem_id="v2v", sources="upload", |
| 242 | ) |
| 243 | with gr.Accordion("The mask of the video to inpaint (视频重新绘制的mask[非必需, Optional])", open=False): |
| 244 | gr.Markdown( |
| 245 | """ |
| 246 | - Please set a larger denoise_strength when using validation_video_mask, such as 1.00 instead of 0.70 |
| 247 | (请设置更大的denoise_strength,当使用validation_video_mask的时候,比如1而不是0.70) |
| 248 | """ |
| 249 | ) |
| 250 | validation_video_mask = gr.Image( |
| 251 | label="The mask of the video to inpaint (视频重新绘制的mask[非必需, Optional])", |
| 252 | show_label=False, elem_id="v2v_mask", sources="upload", type="filepath" |
| 253 | ) |
| 254 | denoise_strength = gr.Slider(label="Denoise strength (重绘系数)", value=0.70, minimum=0.10, maximum=1.00, step=0.01) |
| 255 | |
| 256 | with gr.Column(visible = False) as control_video_col: |
| 257 | gr.Markdown( |
| 258 | """ |