Spaces:
Runtime error
Runtime error
Update app.py
Browse files37 unmodified lines3839404142437 unmodified lines51525354555657585960616263646519 unmodified lines85868788899091929394959697989910010110210310410510613 unmodified lines12012112212312412512641 unmodified lines16816917017117217317417517617717817918018118221 unmodified lines20420520620720820937 unmodified linesnegative_prompt,image,video,mode,steps,num_frames,7 unmodified lines# Part 1. Generate video at smaller resolution# Text-only conditioning is also supported without the need to pass `conditions`expected_height, expected_width = 768, 1152 #todo make configurabledownscale_factor = 2 / 3downscaled_height, downscaled_width = int(expected_height * downscale_factor), int(expected_width * downscale_factor)downscaled_height, downscaled_width = round_to_nearest_resolution_acceptable_by_vae(downscaled_height, downscaled_width)if mode == "text-to-video" and video is not None:video = load_video(video)[:frames_to_use]condition = Trueelif mode == "image-to-video" and image is not None:video = [image]condition = Trueelse:19 unmodified linesoutput_type="latent",).frames# latents = pipe(# conditions=condition1,# prompt=prompt,# negative_prompt=negative_prompt,# # width=downscaled_width,# # height=downscaled_height,# num_frames=num_frames,# num_inference_steps=steps,# decode_timestep = 0.05,# decode_noise_scale = 0.025,# generator=torch.Generator().manual_seed(seed),# #output_type="latent",# ).frames# Part 2. Upscale generated video using latent upsampler with fewer inference steps# The available latent upsampler upscales the height/width by 2x13 unmodified linesheight=upscaled_height,num_frames=num_frames,guidance_scale=1.0,denoise_strength=0.6, # Effectively, 4 inference steps out of 10num_inference_steps=3,latents=upscaled_latents,decode_timestep=0.05,41 unmodified lineswith gr.Column():with gr.Group():with gr.Tab("text-to-video") as text_tab:image = gr.Image(label="", visible=False)#prompt = gr.Textbox(label="prompt")with gr.Tab("image-to-video") as image_tab:image = gr.Image(label="")with gr.Tab("video-to-video") as video_tab:video = gr.Video(label="")frames_to_use = gr.Number(label="num frames to use",info="first # of frames to use from the input video", value=1)prompt = gr.Textbox(label="prompt")improve_texture = gr.Checkbox(label="improve texture", value=False, info="note it slows generation")run_button = gr.Button()with gr.Column():output = gr.Video(interactive=False)21 unmodified linesnegative_prompt,image,video,mode,steps,num_frames,37 unmodified lines38394041424344457 unmodified lines53545556575859606162636465666719 unmodified lines87888990919213 unmodified lines10610710810911011111241 unmodified lines15415515615715815916016116216316416516616721 unmodified lines18919019119219319419519637 unmodified linesnegative_prompt,image,video,height,width,mode,steps,num_frames,7 unmodified lines# Part 1. Generate video at smaller resolution# Text-only conditioning is also supported without the need to pass `conditions`expected_height, expected_width = height, widthdownscale_factor = 2 / 3downscaled_height, downscaled_width = int(expected_height * downscale_factor), int(expected_width * downscale_factor)downscaled_height, downscaled_width = round_to_nearest_resolution_acceptable_by_vae(downscaled_height, downscaled_width)if mode == "text-to-video" and (video is not None):video = load_video(video)[:frames_to_use]condition = Trueelif mode == "image-to-video" and (image is not None):video = [image]condition = Trueelse:19 unmodified linesoutput_type="latent",).frames# Part 2. Upscale generated video using latent upsampler with fewer inference steps# The available latent upsampler upscales the height/width by 2x13 unmodified linesheight=upscaled_height,num_frames=num_frames,guidance_scale=1.0,denoise_strength=0.6, # Effectively, 0.6 * 3 inference stepsnum_inference_steps=3,latents=upscaled_latents,decode_timestep=0.05,41 unmodified lineswith gr.Column():with gr.Group():with gr.Tab("text-to-video") as text_tab:image_n = gr.Image(label="", visible=False)with gr.Tab("image-to-video") as image_tab:image = gr.Image(label="input image")with gr.Tab("video-to-video") as video_tab:video = gr.Video(label="input video")frames_to_use = gr.Number(label="num frames to use",info="first # of frames to use from the input video", value=1)prompt = gr.Textbox(label="prompt")improve_texture = gr.Checkbox(label="improve texture", value=False, info="slows down generation")run_button = gr.Button()with gr.Column():output = gr.Video(interactive=False)21 unmodified linesnegative_prompt,image,video,height,width,mode,steps,num_frames,
app.py+12-25