Matrix-Game icon indicating copy to clipboard operation
Matrix-Game copied to clipboard

File format of input image data

Open haofengl opened this issue 1 year ago • 5 comments

Very excellent work! Can you elaborate on how to construct the input data? Sorry I didn't read the composition of the input data at GameWorldScore, when I directly use Matrix-Game-main/GameWorldScore/asset/init_image as the input path, I get the following error:

Traceback (most recent call last): File "/home/suqian.lhf/video_model/Matrix-Game-main/inference_bench.py", line 317, in main() File "/home/suqian.lhf/video_model/Matrix-Game-main/inference_bench.py", line 313, in main generator.generate_videos() File "/home/suqian.lhf/video_model/Matrix-Game-main/inference_bench.py", line 241, in generate_videos self._process_condition(condition, image_path) File "/home/suqian.lhf/video_model/Matrix-Game-main/inference_bench.py", line 176, in _process_condition video = self.pipeline( File "/home/suqian.lhf/.conda/envs/matrix-game/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, **kwargs) File "/home/suqian.lhf/video_model/Matrix-Game-main/matrixgame/sample/pipeline_matrixgame.py", line 977, in call noise_pred = self.transformer( # For an input image (129, 192, 336) (1, 256, 256) File "/home/suqian.lhf/.conda/envs/matrix-game/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/home/suqian.lhf/.conda/envs/matrix-game/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl return forward_call(*args, **kwargs) File "/home/suqian.lhf/video_model/Matrix-Game-main/teacache_forward.py", line 175, in teacache_forward img, txt = block(*double_block_args) File "/home/suqian.lhf/.conda/envs/matrix-game/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/home/suqian.lhf/.conda/envs/matrix-game/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl return forward_call(*args, **kwargs) File "/home/suqian.lhf/video_model/Matrix-Game-main/matrixgame/model_variants/matrixgame_dit_src/models_i2v.py", line 536, in forward return self.forward_v1(img, txt, vec, cu_seqlens_q, cu_seqlens_kv, max_seqlen_q, max_seqlen_kv, freqs_cis, kwargs, File "/home/suqian.lhf/video_model/Matrix-Game-main/matrixgame/model_variants/matrixgame_dit_src/models_i2v.py", line 249, in forward_v1 attn = attention( File "/home/suqian.lhf/video_model/Matrix-Game-main/matrixgame/model_variants/matrixgame_dit_src/attenion.py", line 128, in attention x, _ = flash_attn_varlen_func( TypeError: 'NoneType' object is not callable

haofengl avatar Jun 23 '25 12:06 haofengl

hello @haofengl, it seems that you haven't installed flash-attn 3 correctly

Brycebywang avatar Jun 23 '25 12:06 Brycebywang

hello @haofengl, it seems that you haven't installed flash-attn 3 correctly

Thanks, my environment is as follows: python 3.10.18 、 torch 2.5.1 、 cuda 12.4 、 apex 0.1、 flash-attn 2.7.4.post1, Are there environmental conflicts?

In addition, I downloaded "https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+ cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl" and executed pip install to install flash-attn and it shows that the installation was successful.

haofengl avatar Jun 24 '25 03:06 haofengl

hello @haofengl, it seems that you haven't installed flash-attn 3 correctly

Thanks, my environment is as follows: python 3.10.18 、 torch 2.5.1 、 cuda 12.4 、 apex 0.1、 flash-attn 2.7.4.post1, Are there environmental conflicts?

In addition, I downloaded "https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+ cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl" and executed pip install to install flash-attn and it shows that the installation was successful.

 This code requires flash-attn3 and is incompatible with flash-attn2

Brycebywang avatar Jun 24 '25 05:06 Brycebywang

@haofengl If you're encountering difficulties installing Flash Attention 3, you can try the following modifications to the code in matrixgame/model_variants/matrixgame_dit_src/attention.py:

  1. Change the import statement:
from flash_attn_interface import flash_attn_varlen_func
--> 
from flash_attn.flash_attn_interface import flash_attn_varlen_func
  1. Modify the function call
x, _ = flash_attn_varlen_func(
            q,
            k,
            v,
            cu_seqlens_q,
            cu_seqlens_kv,
            max_seqlen_q,
            max_seqlen_kv,
        )
-->
x = flash_attn_varlen_func(
            q,
            k,
            v,
            cu_seqlens_q,
            cu_seqlens_kv,
            max_seqlen_q,
            max_seqlen_kv,
        )

ori-gins avatar Jun 25 '25 02:06 ori-gins

@haofengl If you're encountering difficulties installing Flash Attention 3, you can try the following modifications to the code in matrixgame/model_variants/matrixgame_dit_src/attention.py:

  1. Change the import statement:

from flash_attn_interface import flash_attn_varlen_func --> from flash_attn.flash_attn_interface import flash_attn_varlen_func 2. Modify the function call

x, _ = flash_attn_varlen_func( q, k, v, cu_seqlens_q, cu_seqlens_kv, max_seqlen_q, max_seqlen_kv, ) --> x = flash_attn_varlen_func( q, k, v, cu_seqlens_q, cu_seqlens_kv, max_seqlen_q, max_seqlen_kv, )

Thank you very much.

haofengl avatar Jun 25 '25 04:06 haofengl