(self, clip_model)
| 36 | |
| 37 | class TextEncoder(nn.Module): |
| 38 | def __init__(self, clip_model): |
| 39 | super().__init__() |
| 40 | self.transformer = clip_model.transformer |
| 41 | self.positional_embedding = clip_model.positional_embedding |
| 42 | self.ln_final = clip_model.ln_final |
| 43 | self.text_projection = clip_model.text_projection |
| 44 | self.dtype = clip_model.dtype |
| 45 | |
| 46 | def forward(self, prompts, tokenized_prompts): |
| 47 | x = prompts + self.positional_embedding.type(self.dtype) |