sd-webui-deforum icon indicating copy to clipboard operation
sd-webui-deforum copied to clipboard

Fix max_mask_frames AttributeError when using mask video

Open seanlynch opened this issue 1 year ago • 2 comments

This fixes the following traceback that was preventing the use of mask video:

Traceback (most recent call last):
  File "/home/seanl/stable-diffusion-webui/modules/call_queue.py", line 56, in f

    res = list(func(*args, **kwargs))
  File "/home/seanl/stable-diffusion-webui/modules/call_queue.py", line 37, in f

    res = func(*args, **kwargs)
  File "/home/seanl/stable-diffusion-webui/extensions/deforum-for-automatic1111-webui/scripts/deforum.py", line 103, in run_deforum
    render_input_video(args, anim_args, video_args, parseq_args, loop_args, controlnet_args, root.animation_prompts, root)#TODO: prettify code
  File "/home/seanl/stable-diffusion-webui/extensions/deforum-for-automatic1111-webui/scripts/deforum_helpers/render_modes.py", line 48, in render_input_video
    anim_args.max_mask_frames

AttributeError: 'types.SimpleNamespace' object has no attribute 'max_mask_frames'

Tested by successfully using a mask video.

seanlynch avatar Apr 16 '23 01:04 seanlynch

I don't think that max_frames should be adjusted by mask video at all. There is obviously an offending line which should be removed, which is anim_args.max_mask_frames. That doesn't exist. This code was never completed, obviously...

I propose that it should only warn, and that this:

        max_mask_frames = len([f for f in pathlib.Path(mask_in_frame_path).glob('*.jpg')])

        # limit max frames if there are less frames in the video mask compared to input video
        if max_mask_frames < anim_args.max_frames :
            anim_args.max_mask_frames
            print ("Video mask contains less frames than init video, max frames limited to number of mask frames.")

should become this:

        # warn in console if less mask frames than max frames
        max_mask_frames = len([f for f in pathlib.Path(mask_in_frame_path).glob('*.jpg')])
        if max_mask_frames < anim_args.max_frames :
            print ("Video mask contains less frames than init video.")

Or, just delete all of that, and assume the user has a matching mask video.

Otherwise, we should just do an assert that there are enough frames and throw the error.

At the end of the day, I don't know why we would want to defer to the mask frame count to limit the video. The video should limit the video, and the mask frames have to be correct.

reallybigname avatar Apr 16 '23 17:04 reallybigname

Oh, I should add that if you want to do a video with less mask frames, you simply set the end frame of the video to be the end frame of the mask frames, and it only extracts that many video frames.

reallybigname avatar Apr 17 '23 04:04 reallybigname

Closing all PRs as a huge code overhaul PR is coming soon. No pending PR will be compatible with it.

hithereai avatar May 17 '23 10:05 hithereai