Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files536 unmodified lines53753853954054054154254354454554654754854955055155255355455555655765 unmodified lines623624625612626627628629630631618619620621622632633634536 unmodified lines video = pk.interpolate(FILM, video, multiplier) fps = FPS * multiplier
return video, audio, sampling_rate, fps, multiplier # Muxed to an mp4 here, before returning, rather than in the caller: a raw CUDA tensor can't cross a # `@spaces.GPU` return at all under ZeroGPU's CUDA-emulation mode (`RuntimeError: Low-level CUDA init # reached` trying to reconstruct it in the dispatching process), and a CPU float tensor of several hundred # interpolated frames is needlessly large to pickle anyway when the finished file is a few MB of h264. from diffusers.utils import encode_video
frames = (video.permute(0, 2, 3, 1).float() * 255.0).round_().clamp_(0, 255).to(torch.uint8).cpu() del video
directory = os.path.join(tempfile.gettempdir(), "h3-outputs") os.makedirs(directory, exist_ok=True) path = os.path.join(directory, f"h3-ref2va-{int(time.time() * 1000)}.mp4") encode_video(frames, fps=fps, output_path=path, audio=audio, audio_sample_rate=sampling_rate)
return path, fps, multiplier
def generate(65 unmodified lines
progress(0.1, desc=f"Generating {num_frames / FPS:.1f} s at {width}x{height} ...") started = time.time() video, audio, sampling_rate, fps, multiplier = _generate( path, fps, multiplier = _generate( prompt_embeds, text_token_tags, references, height, width, num_frames, steps, seed, sampler_key, schedule_key, float(video_shift), float(audio_shift), float(sharpen), multiplier, ) generate_seconds = time.time() - started
directory = os.path.join(tempfile.gettempdir(), "h3-outputs") os.makedirs(directory, exist_ok=True) path = os.path.join(directory, f"h3-ref2va-{int(time.time() * 1000)}.mp4") encode_video(video, fps=fps, output_path=path, audio=audio, audio_sample_rate=sampling_rate)
print( f"[ref2va] {[kind for kind, _ in references]} 路 `{width}x{height}`, {num_frames} frames " f"({num_frames / FPS:.3f} s), {int(steps)} steps of `{schedule_key}` 路 sampler `{sampler_key}` 路 "app.py+16-7