DiffSynth-Studio icon indicating copy to clipboard operation
DiffSynth-Studio copied to clipboard

How can we cancel currently running generation for Wan 2.1?

Open FurkanGozukara opened this issue 9 months ago • 2 comments

Here your example code

https://github.com/modelscope/DiffSynth-Studio/blob/main/examples/wanvideo/wan_1.3b_text_to_video.py

video = pipe(
    prompt="纪实摄影风格画面,一只活泼的小狗在绿茵茵的草地上迅速奔跑。小狗毛色棕黄,两只耳朵立起,神情专注而欢快。阳光洒在它身上,使得毛发看上去格外柔软而闪亮。背景是一片开阔的草地,偶尔点缀着几朵野花,远处隐约可见蓝天和几片白云。透视感鲜明,捕捉小狗奔跑时的动感和四周草地的生机。中景侧面移动视角。",
    negative_prompt="色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走",
    num_inference_steps=50,
    seed=0, tiled=True
)

How can this command be cancelled any way? I mean lets say 10 steps done and I want to cancel the generation - it doesnt have to return back a video but if returns even better

FurkanGozukara avatar Mar 04 '25 18:03 FurkanGozukara

The only way I see is that pipeline takes a progress_bar_cmd parameter and it defaults to the tqdm which is the progress bar. You may be able to create a wrapper around tqdm that checks an environment variable or enclosed parameter to see if its canceled or not and throw an exception if it is. Then set progress_bar_cmd=your_wrapper. You would have to catch the exception when its thrown. Just my 2 cents.

mstier-nflx avatar Mar 04 '25 22:03 mstier-nflx

The only way I see is that pipeline takes a progress_bar_cmd parameter and it defaults to the tqdm which is the progress bar. You may be able to create a wrapper around tqdm that checks an environment variable or enclosed parameter to see if its canceled or not and throw an exception if it is. Then set progress_bar_cmd=your_wrapper. You would have to catch the exception when its thrown. Just my 2 cents.

can you show how to make this? i mean lets say user wants to cancel current generation. we will hit a gradio button and it will cancel current generation and next will become possible with new params

FurkanGozukara avatar Mar 04 '25 23:03 FurkanGozukara