Spaces:
Runtime error
Runtime error
Update app.py
Browse files61 unmodified lines62636465666768697071722 unmodified lines7576777879808 unmodified lines899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312444 unmodified lines16917017117217317417531 unmodified lines20720820921021121221321421521621721821922024 unmodified lines24524624724824961 unmodified linesname = prompt[:100].replace(" ", "_") + "_" + str(now.time()).replace(":", "_").replace(".", "_")if num_frames == [] or num_frames is None:num_frames = 56else:num_frames = int(num_frames.split(" ")[0])n_autoreg_gen = num_frames//8-8inference_generator = torch.Generator(device="cuda").manual_seed(seed)2 unmodified lineselif model_name_stage1 == "AnimateDiff (text to video)":short_video = ad_short_gen(prompt, ad_model, inference_generator, t, device)elif model_name_stage1 == "SVD (image to video)":short_video = svd_short_gen(image, prompt, svd_model, sdxl_model, inference_generator, t, device)stream_long_gen(prompt, short_video, n_autoreg_gen, seed, t, image_guidance, name, stream_cli, stream_model)8 unmodified linesdef change_visibility(value):if value == "SVD (image to video)":return gr.Image(label='Image Prompt (if not attached then SDXL will be used to generate the starting image)', show_label=True, scale=1, show_download_button=False, interactive=True, type='pil')else:return gr.Image(label='Image Prompt (first select Image-to-Video model from advanced options to enable image upload)', show_label=True, scale=1, show_download_button=False, interactive=False, type='pil')examples = [["Camera moving in a wide bright ice cave.",None, "24 - frames", None, "ModelScopeT2V (text to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],["Explore the coral gardens of the sea: witness the kaleidoscope of colors and shapes as coral reefs provide shelter for a myriad of marine life.",None, "24 - frames", None, "ModelScopeT2V (text to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],["Experience the dance of jellyfish: float through mesmerizing swarms of jellyfish, pulsating with otherworldly grace and beauty.",None, "24 - frames", None, "ModelScopeT2V (text to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],["Discover the secret language of bees: delve into the complex communication system that allows bees to coordinate their actions and navigate the world.",None, "24 - frames", None, "AnimateDiff (text to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],["A beagle reading a paper.",None, "24 - frames", None, "AnimateDiff (text to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],["Beautiful Paris Day and Night Hyperlapse.",None, "24 - frames", None, "AnimateDiff (text to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],["Fishes swimming in ocean camera moving, cinematic.",None, "24 - frames", "__assets__/fish.jpg", "SVD (image to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],["A squirrel on a table full of big nuts.",None, "24 - frames", "__assets__/squirrel.jpg", "SVD (image to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],["Ants, beetles and centipede nest.",None, "24 - frames", None, "SVD (image to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],]# examples = [# ["Fishes swimming in ocean camera moving, cinematic.",# None, "24 - frames", "__assets__/fish.jpg", "SVD (image to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],# ]# --------------------------# ----- Gradio-Demo UI -----44 unmodified lineswith gr.Row():prompt_stage1 = gr.Textbox(label='Textual Prompt', placeholder="Ex: Dog running on the street.")with gr.Row():image_stage1 = gr.Image(label='Image Prompt (first select Image-to-Video model from advanced options to enable image upload)', show_label=True, scale=1, show_download_button=False, interactive=False, type='pil')with gr.Column():video_stage1 = gr.Video(label='Long Video Preview', show_label=True, interactive=False, scale=2, show_download_button=True)with gr.Row():31 unmodified linesinputs_v2v = [prompt_stage1, video_stage1, num_frames, image_stage1, model_name_stage1, model_name_stage2, seed, t, image_guidance]# gr.Examples(examples=examples,# inputs=inputs_v2v,# outputs=video_stage2,# fn=enhance,# run_on_click=False,# # cache_examples=on_huggingspace,# cache_examples=False,# )run_button_stage2.click(fn=enhance, inputs=inputs_v2v, outputs=video_stage2,)'''24 unmodified linesdemo.queue(max_size=20)demo.launch(debug=True)else:_, _, link = demo.queue(api_open=False).launch(share=args.public_access)print(link)61 unmodified lines626364656667686970717273742 unmodified lines7778798081828384858 unmodified lines94959697989910010110210310410510610710810911011111211311411511611711811912012112212312412544 unmodified lines17017117217317417517631 unmodified lines20820921021121221321421521621721821922022122222322422522622722822923023123223324 unmodified lines25825926026161 unmodified linesname = prompt[:100].replace(" ", "_") + "_" + str(now.time()).replace(":", "_").replace(".", "_")if num_frames == [] or num_frames is None:num_frames = 24else:num_frames = int(num_frames.split(" ")[0])if num_frames > 56:num_frames = 56n_autoreg_gen = (num_frames-8)//8inference_generator = torch.Generator(device="cuda").manual_seed(seed)2 unmodified lineselif model_name_stage1 == "AnimateDiff (text to video)":short_video = ad_short_gen(prompt, ad_model, inference_generator, t, device)elif model_name_stage1 == "SVD (image to video)":# For cached examplesif isinstance(image, dict):image = image["path"]short_video = svd_short_gen(image, prompt, svd_model, sdxl_model, inference_generator, t, device)stream_long_gen(prompt, short_video, n_autoreg_gen, seed, t, image_guidance, name, stream_cli, stream_model)8 unmodified linesdef change_visibility(value):if value == "SVD (image to video)":return gr.Image(label='Image Prompt (if not attached then SDXL will be used to generate the starting image)', show_label=True, scale=1, show_download_button=False, interactive=True, value=None)else:return gr.Image(label='Image Prompt (first select Image-to-Video model from advanced options to enable image upload)', show_label=True, scale=1, show_download_button=False, interactive=False, value=None)examples_1 = [["Experience the dance of jellyfish: float through mesmerizing swarms of jellyfish, pulsating with otherworldly grace and beauty.",None, "56 - frames", None, "ModelScopeT2V (text to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],["People dancing in room filled with fog and colorful lights.",None, "56 - frames", None, "ModelScopeT2V (text to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],["Discover the secret language of bees: delve into the complex communication system that allows bees to coordinate their actions and navigate the world.",None, "56 - frames", None, "AnimateDiff (text to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],["sunset, orange sky, warm lighting, fishing boats, ocean waves seagulls, rippling water, wharf, silhouette, serene atmosphere, dusk, evening glow, coastal landscape, seaside scenery.",None, "56 - frames", None, "AnimateDiff (text to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],["Dive into the depths of the ocean: explore vibrant coral reefs, mysterious underwater caves, and the mesmerizing creatures that call the sea home.",None, "56 - frames", None, "SVD (image to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],["Ants, beetles and centipede nest.",None, "56 - frames", None, "SVD (image to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],]examples_2 = [["Fishes swimming in ocean camera moving, cinematic.",None, "56 - frames", "__assets__/fish.jpg", "SVD (image to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],["A squirrel on a table full of big nuts.",None, "56 - frames", "__assets__/squirrel.jpg", "SVD (image to video)", "MS-Vid2Vid-XL", 33, 50, 9.0],]# --------------------------# ----- Gradio-Demo UI -----44 unmodified lineswith gr.Row():prompt_stage1 = gr.Textbox(label='Textual Prompt', placeholder="Ex: Dog running on the street.")with gr.Row():image_stage1 = gr.Image(label='Image Prompt (first select Image-to-Video model from advanced options to enable image upload)', show_label=True, scale=1, show_download_button=False, interactive=False)with gr.Column():video_stage1 = gr.Video(label='Long Video Preview', show_label=True, interactive=False, scale=2, show_download_button=True)with gr.Row():31 unmodified linesinputs_v2v = [prompt_stage1, video_stage1, num_frames, image_stage1, model_name_stage1, model_name_stage2, seed, t, image_guidance]gr.Examples(examples=examples_1,inputs=inputs_v2v,outputs=[video_stage2],fn=enhance,run_on_click=False,cache_examples=True,preprocess=False,postprocess=True,)gr.Examples(examples=examples_2,inputs=inputs_v2v,outputs=[video_stage2],fn=enhance,run_on_click=False,cache_examples=True,preprocess=False,postprocess=True,)run_button_stage2.click(fn=enhance, inputs=inputs_v2v, outputs=video_stage2,)'''24 unmodified linesdemo.queue(max_size=20)demo.launch(debug=True)else:demo.queue(api_open=False).launch(share=args.public_access)
app.py+47-35