:param x: an [N x C x T] tensor. :param t: an [N] tensor. :param images: a batch of images to condition on. :param texts: a batch of texts to condition on. :param embeddings: a batch of CLIP embeddings to condition on. :return: an [N x C' x T] tensor.
(
self,
x: torch.Tensor,
t: torch.Tensor,
images: Optional[Iterable[Optional[ImageType]]] = None,
texts: Optional[Iterable[Optional[str]]] = None,
embeddings: Optional[Iterable[Optional[torch.Tensor]]] = None,
)
| 253 | return dict(embeddings=self.clip(batch_size, **model_kwargs)) |
| 254 | |
| 255 | def forward( |
| 256 | self, |
| 257 | x: torch.Tensor, |
| 258 | t: torch.Tensor, |
| 259 | images: Optional[Iterable[Optional[ImageType]]] = None, |
| 260 | texts: Optional[Iterable[Optional[str]]] = None, |
| 261 | embeddings: Optional[Iterable[Optional[torch.Tensor]]] = None, |
| 262 | ): |
| 263 | """ |
| 264 | :param x: an [N x C x T] tensor. |
| 265 | :param t: an [N] tensor. |
| 266 | :param images: a batch of images to condition on. |
| 267 | :param texts: a batch of texts to condition on. |
| 268 | :param embeddings: a batch of CLIP embeddings to condition on. |
| 269 | :return: an [N x C' x T] tensor. |
| 270 | """ |
| 271 | assert x.shape[-1] == self.n_ctx |
| 272 | |
| 273 | t_embed = self.time_embed(timestep_embedding(t, self.backbone.width)) |
| 274 | clip_out = self.clip(batch_size=len(x), images=images, texts=texts, embeddings=embeddings) |
| 275 | assert len(clip_out.shape) == 2 and clip_out.shape[0] == x.shape[0] |
| 276 | |
| 277 | if self.training: |
| 278 | mask = torch.rand(size=[len(x)]) >= self.cond_drop_prob |
| 279 | clip_out = clip_out * mask[:, None].to(clip_out) |
| 280 | |
| 281 | # Rescale the features to have unit variance |
| 282 | clip_out = math.sqrt(clip_out.shape[1]) * clip_out |
| 283 | |
| 284 | clip_embed = self.clip_embed(clip_out) |
| 285 | |
| 286 | cond = [(clip_embed, self.token_cond), (t_embed, self.time_token_cond)] |
| 287 | return self._forward_with_cond(x, cond) |
| 288 | |
| 289 | |
| 290 | class CLIPImageGridPointDiffusionTransformer(PointDiffusionTransformer): |
nothing calls this directly
no test coverage detected