ls_mlkit.diffuser.conditioner.conditioner module

class ls_mlkit.diffuser.conditioner.conditioner.Conditioner(guidance_scale: float = 1.0)[source]

Bases: ABC

disable()[source]
enable()[source]
abstractmethod get_conditional_score(x_t: Tensor, t: Tensor, padding_mask: Tensor, *args: Any, **kwargs: Any) Tensor[source]

Get conditional score

Parameters:
  • x_t (Tensor) – the input tensor

  • t (Tensor) – the time tensor

  • padding_mask (Tensor) – the padding mask

Returns:

the conditional score

Return type:

Tensor

property guidance_scale
is_enabled() bool[source]
abstractmethod prepare_condition_dict(train: bool = True, *args: list[Any], **kwargs: dict[Any, Any]) dict[str, Any][source]

Prepare the condition dictionary

Parameters:

train (bool, optional) – whether the conditioner is used in training. Defaults to True.

Returns:

the condition dictionary

Return type:

dict[str, Any]

abstractmethod set_condition(*args: list[Any], **kwargs: dict[Any, Any]) None[source]

Set the condition

Parameters:
  • *args – additional arguments

  • **kwargs – additional keyword arguments

property set_guidance_scale
class ls_mlkit.diffuser.conditioner.conditioner.LGDConditioner(guidance_scale: float = 1.0)[source]

Bases: Conditioner

Loss Guidance Conditioner

abstractmethod compute_conditional_loss(x_t: Tensor, t: Tensor, padding_mask: Tensor) Tensor[source]

Compute the conditional loss

Parameters:
  • x_t (Tensor) – the input tensor

  • t (Tensor) – the time tensor

  • padding_mask (Tensor) – the padding mask

Returns:

the conditional loss

Return type:

Tensor

get_conditional_score(x_t: Tensor, t: Tensor, padding_mask: Tensor, *args: Any, **kwargs: Any) Tensor[source]

Get conditional score

Parameters:
  • x_t (Tensor) – the input tensor

  • t (Tensor) – the time tensor

  • padding_mask (Tensor) – the padding mask

Returns:

the conditional score

Return type:

Tensor