Harness Image Generation with the Zelenioncode Custom Model Safetensors

22 Apr 2025
Harness Image Generation with the Zelenioncode Custom Model Safetensors

In the realm of artificial intelligence and machine learning, image generation has taken center stage, allowing developers to create stunning visuals based on textual descriptions. The Zelenioncode Custom Model Safetensors provides a powerful Cognitive Action to generate images using the DreamBooth safetensors model with RealVisXL. This model offers a plethora of customization options, ensuring that the generated images are not only high-quality but also closely aligned with the provided prompts.

Prerequisites

Before diving into the integration of Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of making HTTP requests in your programming language of choice.
  • A development environment set up to run your code.

Authentication with the Cognitive Actions API typically involves passing your API key in the request headers, which will allow you to securely access the available actions.

Cognitive Actions Overview

Generate Image Using DreamBooth RealVisXL

This action utilizes the DreamBooth safetensors model with RealVisXL for generating images. It offers several customization options, such as dimensions, the number of pictures, guidance scale, and scheduling algorithm, ensuring high precision and alignment with textual prompts.

Input

The input for this action is structured as follows:

FieldTypeDescription
seedIntegerAn integer seed for random number generation, used for reproducibility. Default is 1334.
widthIntegerThe width of the generated image in pixels. Must be an integer. Default is 768.
heightIntegerThe height of the generated image in pixels. Must be an integer. Default is 1024.
promptStringA textual description guiding image generation. Default is a sample prompt for generating images.
guidanceScaleIntegerControls how closely the output matches the prompt. Higher values lead to closer alignment. Default is 7.
safeTensorsLinkStringURL linking to a safetensors model file for loading model weights. Default is a preset link.
numberOfPicturesIntegerThe number of pictures to generate, ranging from 1 to 4. Default is 1.
negativeTextPromptStringDescription of elements to avoid in the output image, refining the generated result.
schedulingAlgorithmStringThe algorithm for scheduling inference steps during the generation process. Default is DDIM.
numberOfInferenceStepsIntegerThe number of inference steps taken to generate the image. More steps can improve quality at the cost of speed. Default is 40.

Example Input:

{
  "seed": 3456051406,
  "width": 768,
  "height": 1024,
  "prompt": "photograph of casual sophisticated ohwx woman, looking camera, classic side part, tailored black three-piece suit, skin imperfections, 8k uhd, dsir, soft lighting, high quality, film grain, Fujifilm XT3",
  "guidanceScale": 7,
  "numberOfPictures": 4,
  "negativeTextPrompt": "Tattoos, (deformed iris, deformed pupils, semi-realistic, gi, 3d, render, sketch, cartoon, drawing, anime), text, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, UnrealisticDream",
  "numberOfInferenceSteps": 40
}

Output

Upon successful execution of this action, the output returns an array of URLs pointing to the generated images. Here’s a sample of the expected output:

[
  "https://assets.cognitiveactions.com/invocations/5a3985e0-7057-4d8c-9d25-8f1708e4dfe4/f625b1da-3aa1-4adb-8695-cf93f91b6405.png",
  "https://assets.cognitiveactions.com/invocations/5a3985e0-7057-4d8c-9d25-8f1708e4dfe4/43c4f9a6-a39e-449d-a4fa-e7c0fce42748.png",
  "https://assets.cognitiveactions.com/invocations/5a3985e0-7057-4d8c-9d25-8f1708e4dfe4/045aae5f-3b95-4112-9365-fc1d0d21a619.png",
  "https://assets.cognitiveactions.com/invocations/5a3985e0-7057-4d8c-9d25-8f1708e4dfe4/a98ff67a-5827-4d70-9b9b-ad37b7188eec.png"
]

Conceptual Usage Example (Python)

Here’s how you might call this action using a hypothetical Cognitive Actions execution endpoint in Python:

import requests
import json

# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint

action_id = "76ca3d03-ba0a-4f09-b30a-d12962cc82d7" # Action ID for Generate Image Using DreamBooth RealVisXL

# Construct the input payload based on the action's requirements
payload = {
    "seed": 3456051406,
    "width": 768,
    "height": 1024,
    "prompt": "photograph of casual sophisticated ohwx woman, looking camera, classic side part, tailored black three-piece suit, skin imperfections, 8k uhd, dsir, soft lighting, high quality, film grain, Fujifilm XT3",
    "guidanceScale": 7,
    "numberOfPictures": 4,
    "negativeTextPrompt": "Tattoos, (deformed iris, deformed pupils, semi-realistic, gi, 3d, render, sketch, cartoon, drawing, anime), text, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, UnrealisticDream",
    "numberOfInferenceSteps": 40
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload} # Hypothetical structure
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body: {e.response.text}")

In this code snippet, you'll replace the placeholder API key and endpoint with your actual credentials. The action ID is specified, and the input payload is structured according to the defined schema. This example demonstrates how to execute the action, handle errors, and print out the resulting image URLs.

Conclusion

The Zelenioncode Custom Model Safetensors provides a robust tool for developers looking to implement image generation capabilities in their applications. By effectively utilizing the Generate Image Using DreamBooth RealVisXL action, you can create visually stunning outputs that align with your specified prompts. As you explore the possibilities of this Cognitive Action, consider integrating it into various use cases, such as art generation, marketing materials, or personalized content creation. Happy coding!