2D Image to Patch Embedding
| 64 | |
| 65 | |
| 66 | class PatchEmbed_Video(PatchEmbed): |
| 67 | """2D Image to Patch Embedding""" |
| 68 | |
| 69 | def __init__(self, *args, **kwargs): |
| 70 | super().__init__(*args, **kwargs) |
| 71 | |
| 72 | def forward(self, x): |
| 73 | B, T, C, H, W = x.shape |
| 74 | x = rearrange(x, "b t c h w -> (b t) c h w") |
| 75 | x = super().forward(x) |
| 76 | # (b t) n c |
| 77 | x = rearrange(x, "(b t) n c -> b (t n) c", t=T) |
| 78 | return x |
| 79 | |
| 80 | |
| 81 | def exists(val): |