MCPcopy Create free account
hub / github.com/Shakker-Labs/RepText / check_inputs

Method check_inputs

pipeline_flux_controlnet.py:485–531  ·  view source on GitHub ↗
(
        self,
        prompt,
        prompt_2,
        height,
        width,
        prompt_embeds=None,
        pooled_prompt_embeds=None,
        callback_on_step_end_tensor_inputs=None,
        max_sequence_length=None,
    )

Source from the content-addressed store, hash-verified

483 return timesteps, num_inference_steps - t_start
484
485 def check_inputs(
486 self,
487 prompt,
488 prompt_2,
489 height,
490 width,
491 prompt_embeds=None,
492 pooled_prompt_embeds=None,
493 callback_on_step_end_tensor_inputs=None,
494 max_sequence_length=None,
495 ):
496 if height % 8 != 0 or width % 8 != 0:
497 raise ValueError(f"`height` and `width` have to be divisible by 8 but are {height} and {width}.")
498
499 if callback_on_step_end_tensor_inputs is not None and not all(
500 k in self._callback_tensor_inputs for k in callback_on_step_end_tensor_inputs
501 ):
502 raise ValueError(
503 f"`callback_on_step_end_tensor_inputs` has to be in {self._callback_tensor_inputs}, but found {[k for k in callback_on_step_end_tensor_inputs if k not in self._callback_tensor_inputs]}"
504 )
505
506 if prompt is not None and prompt_embeds is not None:
507 raise ValueError(
508 f"Cannot forward both `prompt`: {prompt} and `prompt_embeds`: {prompt_embeds}. Please make sure to"
509 " only forward one of the two."
510 )
511 elif prompt_2 is not None and prompt_embeds is not None:
512 raise ValueError(
513 f"Cannot forward both `prompt_2`: {prompt_2} and `prompt_embeds`: {prompt_embeds}. Please make sure to"
514 " only forward one of the two."
515 )
516 elif prompt is None and prompt_embeds is None:
517 raise ValueError(
518 "Provide either `prompt` or `prompt_embeds`. Cannot leave both `prompt` and `prompt_embeds` undefined."
519 )
520 elif prompt is not None and (not isinstance(prompt, str) and not isinstance(prompt, list)):
521 raise ValueError(f"`prompt` has to be of type `str` or `list` but is {type(prompt)}")
522 elif prompt_2 is not None and (not isinstance(prompt_2, str) and not isinstance(prompt_2, list)):
523 raise ValueError(f"`prompt_2` has to be of type `str` or `list` but is {type(prompt_2)}")
524
525 if prompt_embeds is not None and pooled_prompt_embeds is None:
526 raise ValueError(
527 "If `prompt_embeds` are provided, `pooled_prompt_embeds` also have to be passed. Make sure to generate `pooled_prompt_embeds` from the same text encoder that was used to generate `prompt_embeds`."
528 )
529
530 if max_sequence_length is not None and max_sequence_length > 512:
531 raise ValueError(f"`max_sequence_length` cannot be greater than 512 but is {max_sequence_length}")
532
533 @staticmethod
534 # Copied from diffusers.pipelines.flux.pipeline_flux.FluxPipeline._prepare_latent_image_ids

Callers 1

__call__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected