MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / main

Function main

examples/WanVSR/infer_flashvsr_tiny_long_video.py:200–232  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

198 return pipe
199
200def main():
201 RESULT_ROOT = "./results"
202 os.makedirs(RESULT_ROOT, exist_ok=True)
203 inputs = [
204 "./inputs/example4.mp4",
205 ]
206 seed, scale, dtype, device = 0, 4.0, torch.bfloat16, 'cuda'
207 sparse_ratio = 2.0 # Recommended: 1.5 or 2.0. 1.5 → faster; 2.0 → more stable.
208 pipe = init_pipeline()
209
210 for p in inputs:
211 torch.cuda.empty_cache(); torch.cuda.ipc_collect()
212 name = os.path.basename(p.rstrip('/'))
213 if name.startswith('.'):
214 continue
215 try:
216 LQ, th, tw, F, fps = prepare_input_tensor(p, scale=scale, dtype=dtype, device=device)
217 except Exception as e:
218 print(f"[Error] {name}: {e}"); continue
219
220 video = pipe(
221 prompt="", negative_prompt="", cfg_scale=1.0, num_inference_steps=1, seed=seed,
222 LQ_video=LQ, num_frames=F, height=th, width=tw, is_full_block=False, if_buffer=True,
223 topk_ratio=sparse_ratio*768*1280/(th*tw),
224 kv_ratio=3.0,
225 local_range=11, # Recommended: 9 or 11. local_range=9 → sharper details; 11 → more stable results.
226 color_fix = True,
227 )
228
229 video = tensor2video(video)
230 save_video(video, os.path.join(RESULT_ROOT, f"FlashVSR_Tiny_Long_{name.split('.')[0]}_seed{seed}.mp4"), fps=fps, quality=5)
231
232 print("Done.")
233
234if __name__ == "__main__":
235 main()

Calls 4

init_pipelineFunction · 0.70
prepare_input_tensorFunction · 0.70
tensor2videoFunction · 0.70
save_videoFunction · 0.70

Tested by

no test coverage detected