Docs /Templates/ sinapsis-huggingface-diffusers

InpaintingDiffusers

sinapsis-huggingface-diffusersHuggingFacehuggingfacediffusersmodelsgenerative

Python template · sinapsis_huggingface_diffusers.templates.inpainting_diffusers

Overview

This class implements a specific template for inpainting tasks using Hugging Face's diffusers. The `InpaintingDiffusers` class inherits from `ImageToImageDiffusers` and extends its capabilities to handle inpainting using bounding boxes to create masks or directly using segmentation masks.

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

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
int | list[int] | None
Optional
Default: null
deviceRequired
typing.Literal['cuda', 'cpu']
Required
Default: null
metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
model_path
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
typing.Literal['float16', 'float32']
Optional
Default: "float16"
dilation_radius

Radius of the surrounding area (in pixels) to include around the mask. If None, no dilation is applied. Defaults to None.

int | None
Optional
Default: null
inpainting_modeRequired

Determines how the inpainting mask is generated. - "bbox": Generate masks based on bounding box annotations. - "mask": Use segmentation masks or polygons to generate the mask.

typing.Literal['bbox', 'mask']
Required
Default: null
model_cache_dir
str
Optional
Default: "/home/ariel/.cache/sinapsis"
overwrite_images
bool
Optional
Default: false
generation_params
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
bool
Optional
Default: false
preserve_outside_content

If True, preserves the content outside the mask by blending the new content with the old content. Defaults to False.

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: InpaintingDiffusers
  class_name: InpaintingDiffusers
  template_input: InputTemplate
  attributes:
    model_path: '/path/to/diffusers/model'
    model_cache_dir: /path/to/cache/dir
    device: 'cuda'
    torch_dtype: float16
    enable_model_cpu_offload: false
    generation_params: {}
    overwrite_images: false
    inpainting_mode: 'bbox'
    dilation_radius: 2
    preserve_outside_content: false
Show schema-based configuration skeleton
yaml
templates:
  - template_name: "InpaintingDiffusers"
    class_name: "InpaintingDiffusers"
    attributes:
      seed: null
      device: "<required>"
      model_path: "stable-diffusion-v1-5/stable-diffusion-v1-5"
      torch_dtype: "float16"
      dilation_radius: null
      inpainting_mode: "<required>"
      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
      preserve_outside_content: false

Inheritance

Immediate parent: sinapsis_huggingface_diffusers.templates.image_to_image_diffusers.ImageToImageDiffusers

Environment variables

Environment definitions belong to their canonical Python modules.

No directly related environment variables listed.