Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The shape of the 2D attn_mask is torch.Size([77, 77]), but should be (1, 1). #26

Open
aditya-raj0 opened this issue Jan 28, 2025 · 1 comment

Comments

@aditya-raj0
Copy link

So, i an running the code as recommended in the readme with the default video and prompt. and i an getting this error:

./video_super_resolution/scripts/inference_sr.sh
MP4 files to be processed:
./input/video/023_klingai_reedit.mp4
Number of MP4 files: 1
Number of lines in the text file: 1
Processing video file: ./input/video/023_klingai_reedit.mp4 with prompt: A serene scene of a panda bear playing a guitar at sunset unfolds by a tranquil lake. The panda, with its black-and-white fur, strums the guitar while seated on a rock. Behind, a breathtaking mountain range glows under the orange and pink hues of the setting sun, contrasting beautifully with the lake's deep blue. The composition highlights the panda's relaxed interaction with the guitar, set against the stunning natural landscape, creating depth and peaceful harmony.
2025-01-28 22:46:54,867 - video_to_video - INFO - checkpoint_path: ./pretrained_weight/heavy_deg.pt
2025-01-28 22:47:21,817 - video_to_video - INFO - Build encoder with FrozenOpenCLIPEmbedder
/home/adity/STAR/video_to_video/video_to_video_model.py:37: FutureWarning: You are using torch.load with weights_only=False (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for weights_only will be flipped to True. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=True for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
load_dict = torch.load(cfg.model_path, map_location='cpu')
2025-01-28 22:48:14,757 - video_to_video - INFO - Load model path ./pretrained_weight/heavy_deg.pt, with local status
2025-01-28 22:48:14,787 - video_to_video - INFO - Build diffusion with GaussianDiffusion
2025-01-28 22:48:15,956 - video_to_video - INFO - Build Temporal VAE
Traceback (most recent call last):
File "/home/adity/STAR/./video_super_resolution/scripts/inference_sr.py", line 137, in
main()
File "/home/adity/STAR/./video_super_resolution/scripts/inference_sr.py", line 122, in main
star = STAR(
File "/home/adity/STAR/./video_super_resolution/scripts/inference_sr.py", line 41, in init
self.model = VideoToVideo_sr(model_cfg)
File "/home/adity/STAR/video_to_video/video_to_video_model.py", line 71, in init
negative_y = text_encoder(self.negative_prompt).detach()
File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
File "/home/adity/STAR/video_to_video/modules/embedder.py", line 51, in forward
z = self.encode_with_transformer(tokens.to(self.device))
File "/home/adity/STAR/video_to_video/modules/embedder.py", line 58, in encode_with_transformer
x = self.text_transformer_forward(x, attn_mask=self.model.attn_mask)
File "/home/adity/STAR/video_to_video/modules/embedder.py", line 71, in text_transformer_forward
x = r(x, attn_mask=attn_mask)
File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
File "/opt/conda/lib/python3.10/site-packages/open_clip/transformer.py", line 263, in forward
x = q_x + self.ls_1(self.attention(q_x=self.ln_1(q_x), k_x=k_x, v_x=v_x, attn_mask=attn_mask))
File "/opt/conda/lib/python3.10/site-packages/open_clip/transformer.py", line 250, in attention
return self.attn(
File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/activation.py", line 1368, in forward
attn_output, attn_output_weights = F.multi_head_attention_forward(
File "/opt/conda/lib/python3.10/site-packages/torch/nn/functional.py", line 6131, in multi_head_attention_forward
raise RuntimeError(
RuntimeError: The shape of the 2D attn_mask is torch.Size([77, 77]), but should be (1, 1).
All videos processed successfully.

Where does the issue actually lie?

@yhliu04
Copy link
Collaborator

yhliu04 commented Jan 30, 2025

This issue is caused by the version of the open-clip-torch library. You should install the required version as specified in the requirements file: open-clip-torch==2.20.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants