volotat / SD-CN-Animation

This script allows to automate video stylization task using StableDiffusion and ControlNet.
MIT License
806 stars 61 forks source link

operands could not be broadcast together with shapes (288,520,3) (290,520,3) #110

Open lj350201364 opened 1 year ago

lj350201364 commented 1 year ago

operands could not be broadcast together with shapes (288,520,3) (290,520,3)

I found that this problem occurs when I manually input through the input box, but it is normal to drag with the progress bar

Lalimec commented 1 year ago

i ve hust got this error. and it is possible that the cause is odd resolutions. anything different from slider values is not suitable for stable diffusion.

francescozaia commented 1 year ago

I'm also having the broadcast error on this line https://github.com/volotat/SD-CN-Animation/blob/2e257bbfc3b76fb1323f7b22f820981c1b9f56b2/scripts/core/vid2vid.py#L222

I'm actually not doing anything fancy, except for the fact I'm on Apple M1, so I had to change https://github.com/volotat/SD-CN-Animation/blob/2e257bbfc3b76fb1323f7b22f820981c1b9f56b2/scripts/core/flow_utils.py#L55 to RAFT_model.load_state_dict(torch.load(args.model, map_location=device)) due to #131

Attempted fixes: I tried to update https://github.com/volotat/SD-CN-Animation/blob/2e257bbfc3b76fb1323f7b22f820981c1b9f56b2/scripts/core/vid2vid.py#L238 with processed_frame = np.array(processed_frames[0])[...,:3] following what @volotat did on #92, but with no luck.

I guess it's a matter of matrix multiplication with the * sign, but I'm probably wrong as I'm no expert in the field.

jfranecki commented 1 year ago

I'm also having this issue while trying to maintain a 9:16 aspect ratio. I can generate a video at 1080x1920(my input resolution) and 720x1280 but the models don't work well with frames that large. My thought was that both numbers need to be divisible by 3 but it doesn't work for 540x960.

An exception occurred while trying to process the frame: operands could not be broadcast together with shapes (960,536,3) (960,540,3)

Update: 512x912 works for me while retaining a 9:16 ratio. So does 528x944.

JumpIntoCoding commented 1 year ago

I faced with the same issue and solved it by a trick (not a real solution). I guess the problem is that your input video-frame width and height and the first SD-CN-Animation extension processed video-frame W&H do not match. The solution is set the input video W&H to what you see in error trace. For example if you see "An exception occurred while trying to process the frame: operands could not be broadcast together with shapes (960,536,3) (960,540,3)". then check you W&H setting in extension (which is 960 & 536 in the above case). and then just change the W&H setting to 960 & 540, it might casuse the video to be a bit distorted in W&H ratio, but it is a easy solution that worth a try.

image