TextToImageDiffusers
Python template · sinapsis_huggingface_diffusers.templates.text_to_image_diffusers
Overview
This class implements a specific template for text-to-image generation using Hugging Face's diffusers. The `TextToImageDiffusers` class inherits from the base `BaseDiffusers` class to define how to handle text-based prompts for generating images.
Parameters to be used inside generation_params can be seen at HuggingFace documentation: https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/text2img
Capabilities
Capabilities: not setInstallation
Install the published package using pip or uv.
pip install sinapsis-huggingface-diffusers==1.0.0uv pip install sinapsis-huggingface-diffusers==1.0.0uv add sinapsis-huggingface-diffusers==1.0.0Configuration
Effective fields from the inspector schema, including nested Pydantic model fields.
Random seed(s) for reproducibility.
Optional
Default: null
Device for computations, either "cpu" or "cuda".
Required
Default: null
Optional
Default: null
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.
Optional
Default: "stable-diffusion-v1-5/stable-diffusion-v1-5"
Data type for PyTorch tensors.
Optional
Default: "float16"
Directory to cache and save the models.
Optional
Default: "/home/ariel/.cache/sinapsis"
Whether to overwrite the existing images in the container. Defaults to False.
Optional
Default: false
Parameters for image generation (e.g., prompt, guidance_scale).
Optional
Default: null
The width in pixels of the generated image.
Optional
Default: null
The height in pixels of the generated image.
Optional
Default: null
The text prompt(s) to guide image generation.
Optional
Default: null
Controls how much the prompt influences the output. Higher values mean stronger adherence. Defaults to 7.5.
Optional
Default: 7.5
Prompt(s) to guide the model away from generating certain things.
Optional
Default: null
The number of denoising steps. More steps typically result in higher quality but are slower. Defaults to 50.
Optional
Default: 50
The number of images to generate per prompt. Defaults to 1.
Optional
Default: 1
If True, enables CPU offloading to reduce GPU memory usage.
Optional
Default: false
Configuration example
Example from the Python docstring:
agent:
name: my_test_agent
templates:
- template_name: InputTemplate
class_name: InputTemplate
attributes: {}
- template_name: TextToImageDiffusers
class_name: TextToImageDiffusers
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: {}Show schema-based configuration skeleton
templates:
- template_name: "TextToImageDiffusers"
class_name: "TextToImageDiffusers"
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
sinapsis_huggingface_diffusers.templates.base_diffusers.BaseDiffusersEnvironment variables
Environment definitions belong to their canonical Python modules.
No directly related environment variables listed.