Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files536 unmodified lines53753853954054154254365 unmodified lines609610611612613614615616617618619620621622623624625536 unmodified linesvideo = pk.interpolate(FILM, video, multiplier)fps = FPS * multiplierreturn video, audio, sampling_rate, fps, multiplierdef generate(65 unmodified linesprogress(0.1, desc=f"Generating {num_frames / FPS:.1f} s at {width}x{height} ...")started = time.time()video, audio, sampling_rate, 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() - starteddirectory = 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}` 路 "536 unmodified lines53753853954054154254354454554654754854955055155255355455555655765 unmodified lines623624625626627628629630631632633634536 unmodified linesvideo = pk.interpolate(FILM, video, multiplier)fps = 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_videoframes = (video.permute(0, 2, 3, 1).float() * 255.0).round_().clamp_(0, 255).to(torch.uint8).cpu()del videodirectory = 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, multiplierdef generate(65 unmodified linesprogress(0.1, desc=f"Generating {num_frames / FPS:.1f} s at {width}x{height} ...")started = time.time()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() - startedprint(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