Skip to main content
Version: 2024.3

Hugging Face Image To Image Prompt

This Action generates images using AI models based on an already existing image. Depending on the configuration, the generated image can be saved a separate asset or overwrite the content of the selected asset. Note: For the action to work, you need to select exactly one element. Selection of none or more than one element is currently not supported and will result in an error.

Available Context

For more information on context limitations refer to the "Available Context section" in the Pimcore Copilot documentation here.

Multiselect: No Elements: Images

Configuration Options

# Specifies the model's endpoint. A full URL overrides the default base URL. This is where the API requests for image generation are sent.
model_endpoint: 'https://api-inference.huggingface.co/models/timbrooks/instruct-pix2pix'

# new or overwrite.
persistence_mode: new

# Specifies the folder for storing generated images. This path is where the generated images will be saved.
asset_folder: '/AI Generated'

# Twig template that will be used as a suffix for the filename. Default: _upscaled
filename_suffix_template: "{{ subject.getId() }}-{{ random() }}"

# Twig template for creating the prompt sent to the image generation model. It combines the input fields into a coherent description.
prompt_template: "Change the color of the car to blue."

parameters: # Optional parameters for the image generation.
negative_prompt: "ugly, deformed, disfigured, poor details, bad anatomy" # Descriptions to avoid in the generated images.
guidance_scale: 9 # How strongly the generated image should adhere to the prompt versus the model's own creativity.
image_guidance_scale: 1.1 # Higher image guidance scale encourages generated images that are closely linked to the source image, usually at the expense of lower image quality
num_inference_steps: 10 # The number of steps the model takes to refine the generated image. Higher values can lead to more detailed images.

options:
# Uses cached images for similar requests to speed up response times. Set to false for new images per request. This can improve efficiency when similar prompts are used frequently.
use_cache: true

Detailed Configuration Options

  • model_endpoint: (Required) Specifies the endpoint for the model you want to use for image generation. The default base URL is https://api-inference.huggingface.co. Providing just the model name defaults to this URL. A full URL, such as 'https://api-inference.huggingface.co/models/timbrooks/instruct-pix2pix', overrides the default. This is where API requests for image generation are sent.
  • persistence_mode: (Required) New or overwrite. If set to new, the generated image is saved as a separate asset. If set to overwrite, the generated image overwrites the content of the selected asset.
  • asset_folder: (Optional). Designates the folder where generated images will be stored. Default: /
  • filename_suffix_template: (Optional) Twig template that will be used as a suffix for the filename. Default: _upscaled.
  • prompt_template: (Required) A Twig template that creates the prompt sent to the image generation model. It combines the input fields into a coherent description for the model. The selected element gets passed as "subject". If empty, the user has to input the initial prompt manually.
  • parameters: (Optional) Optional parameters for the image generation.
    • negative_prompt: A Twig template that specifies descriptions to avoid in the generated images.
    • guidance_scale: How strongly the generated image should adhere to the prompt versus the model's own creativity.
    • num_inference_steps: The number of steps the model takes to refine the generated image.
    • image_guidance_scale: Higher image guidance scale encourages generated images that are closely linked to the source image, usually at the expense of lower image quality.
  • options: (Optional) Additional options for the image generation process.
    • use_cache: Utilizes cached generated images for similar requests to speed up response times. Set to false for generating new images for every request. This option can improve efficiency when similar prompts are used frequently.