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

Function main

examples/WanVSR/infer_flashvsr_tiny.py:196–230  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 4

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

Tested by

no test coverage detected