Docs /Templates/ sinapsis-huggingface-diffusers

ImageToImageDiffusers

sinapsis-huggingface-diffusersHuggingFacehuggingfacediffusersmodelsgenerative

Python template · sinapsis_huggingface_diffusers.templates.image_to_image_diffusers

Overview

Template for the image-to-image generative task using diffusers.

This class extends the base `BaseDiffusers` class to provide an implementation for the specific image-to-image generation using HuggingFace's Diffusers.

Parameters to be used inside generation_params can be seen at HuggingFace documentation: https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/img2img

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis-huggingface-diffusers==1.0.0
uv pip install sinapsis-huggingface-diffusers==1.0.0
uv add sinapsis-huggingface-diffusers==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

seed

Random seed(s) for reproducibility.

int | list[int] | None
Optional
Default: null
deviceRequired

Device for computations, either "cpu" or "cuda".

typing.Literal['cuda', 'cpu']
Required
Default: null
metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
model_path

The path or identifier of the pre-trained model to load. - Can be a repository ID from Hugging Face's model hub (e.g., "CompVis/stable-diffusion-v1-4"). - Can also be a local directory path containing the model weights and configuration files.

typing.Literal['stable-diffusion-v1-5/stable-diffusion-v1-5', 'stabilityai/stable-diffusion-2-1', 'CompVis/stable-diffusion-v1-4', 'Qwen/Qwen-Image-Edit']
Optional
Default: "stable-diffusion-v1-5/stable-diffusion-v1-5"
torch_dtype

Data type for PyTorch tensors.

typing.Literal['float16', 'float32']
Optional
Default: "float16"
model_cache_dir

Directory to cache and save the models.

str
Optional
Default: "/home/ariel/.cache/sinapsis"
overwrite_images

Whether to overwrite the existing images in the container. Defaults to False.

bool
Optional
Default: false
generation_params

Parameters for image generation (e.g., prompt, guidance_scale).

BaseGenerationParams
Optional
Default: null
width

The width in pixels of the generated image.

int | None
Optional
Default: null
height

The height in pixels of the generated image.

int | None
Optional
Default: null
prompt

The text prompt(s) to guide image generation.

str | list[str] | None
Optional
Default: null
guidance_scale

Controls how much the prompt influences the output. Higher values mean stronger adherence. Defaults to 7.5.

float | None
Optional
Default: 7.5
negative_prompt

Prompt(s) to guide the model away from generating certain things.

str | list[str] | None
Optional
Default: null
num_inference_steps

The number of denoising steps. More steps typically result in higher quality but are slower. Defaults to 50.

int | None
Optional
Default: 50
num_images_per_prompt

The number of images to generate per prompt. Defaults to 1.

int | None
Optional
Default: 1
enable_model_cpu_offload

If True, enables CPU offloading to reduce GPU memory usage.

bool
Optional
Default: false

Configuration example

Example from the Python docstring:

yaml
agent:
  name: my_test_agent
templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}
- template_name: ImageToImageDiffusers
  class_name: ImageToImageDiffusers
  template_input: InputTemplate
  attributes:
    model_path: '/path/to/diffusers/model'
    model_cache_dir: /path/to/sinapsis/cache/dir
    device: 'cuda'
    torch_dtype: float16
    enable_model_cpu_offload: false
    generation_params: {}
    overwrite_images: false
Show schema-based configuration skeleton
yaml
templates:
  - template_name: "ImageToImageDiffusers"
    class_name: "ImageToImageDiffusers"
    attributes:
      seed: null
      device: "<required>"
      model_path: "stable-diffusion-v1-5/stable-diffusion-v1-5"
      torch_dtype: "float16"
      model_cache_dir: "/home/ariel/.cache/sinapsis"
      overwrite_images: false
      generation_params:
        width: null
        height: null
        prompt: null
        guidance_scale: 7.5
        negative_prompt: null
        num_inference_steps: 50
        num_images_per_prompt: 1
      enable_model_cpu_offload: false

Inheritance

Immediate parent: sinapsis_huggingface_diffusers.templates.base_diffusers.BaseDiffusers

Environment variables

Environment definitions belong to their canonical Python modules.

No directly related environment variables listed.