(batch, text_encoder, clip_tokenizer, caption_column)
| 330 | |
| 331 | |
| 332 | def encode_prompt(batch, text_encoder, clip_tokenizer, caption_column): |
| 333 | prompt = batch[caption_column] |
| 334 | if isinstance(prompt[0], list): |
| 335 | prompt = [p[0] for p in prompt] |
| 336 | with torch.no_grad(): |
| 337 | text_inputs = clip_tokenizer( |
| 338 | prompt, |
| 339 | padding="max_length", |
| 340 | max_length=clip_tokenizer.model_max_length, |
| 341 | truncation=True, |
| 342 | return_tensors="pt" |
| 343 | ) |
| 344 | input_ids = text_inputs.input_ids |
| 345 | prompt_embeds = text_encoder( |
| 346 | input_ids.to(text_encoder.device), |
| 347 | )[0] |
| 348 | return {"prompt_embeds": prompt_embeds.cpu()} |
| 349 | |
| 350 | |
| 351 | def encode_images(batch, image_vae, image_encoder, clip_image_processor, label_vae, image_column): |
nothing calls this directly
no outgoing calls
no test coverage detected