Create Unique Toy Story Character Images with Cognitive Actions

24 Apr 2025
Create Unique Toy Story Character Images with Cognitive Actions

Integrating creative AI into your applications has never been easier with the fofr/sdxl-toy-story-people Cognitive Actions. This powerful set of pre-built actions allows developers to generate stunning images styled after beloved characters from the classic film Toy Story (1995). Leveraging the capabilities of the SDXL model fine-tuned on these iconic characters, you can enhance your applications with imaginative visuals tailored to your specifications.

Prerequisites

Before you dive into using the Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Basic knowledge of JSON structure, as you will be constructing input payloads in this format.

Authentication typically involves passing your API key in the headers of your requests.

Cognitive Actions Overview

Generate Toy Story Character Image

This action generates images of people styled after characters from Toy Story, offering flexibility in image generation modes such as img2img and inpainting. It supports a variety of customization options, including image resolution, guidance scale, and refinement styles.

Input:

  • mask (optional): URI for the input mask used in inpaint mode.
  • image (optional): URI for the input image used in img2img or inpaint mode.
  • width (integer, default: 1024): Width of the output image in pixels.
  • height (integer, default: 1024): Height of the output image in pixels.
  • prompt (string, default: "An astronaut riding a rainbow unicorn"): Text prompt guiding the image generation.
  • randomSeed (optional): Seed for random number generation.
  • loraWeights (optional): LoRA weights to apply during processing.
  • guidanceScale (number, default: 7.5): Intensity of classifier-free guidance (1-50).
  • applyWatermark (boolean, default: true): Applies a watermark to the generated image.
  • negativePrompt (string, default: ""): Specifies elements to avoid in the generated image.
  • promptStrength (number, default: 0.8): Strength of the prompt's influence (0-1).
  • refinementSteps (optional): Number of refinement steps for the 'base_image_refiner' style.
  • refinementStyle (string, default: "no_refiner"): Specifies the refinement method.
  • outputImageCount (integer, default: 1): Total number of images to generate (1-4).
  • schedulingMethod (string, default: "K_EULER"): Algorithm used for scheduling during processing.
  • highNoiseFraction (number, default: 0.8): Fraction of noise applied in 'expert_ensemble_refiner'.
  • inferenceStepCount (integer, default: 50): Number of steps during denoising (1-500).
  • loraAdjustmentScale (number, default: 0.6): Scale of additive effect when using LoRA.
  • safetyCheckerDisabled (boolean, default: false): Toggle to disable the safety checker.

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "An animated TOK Elon Musk person, 90s animation",
  "guidanceScale": 7.5,
  "applyWatermark": false,
  "negativePrompt": "broken, distorted, ugly, two people",
  "promptStrength": 0.8,
  "refinementStyle": "expert_ensemble_refiner",
  "outputImageCount": 1,
  "schedulingMethod": "K_EULER",
  "highNoiseFraction": 0.9,
  "inferenceStepCount": 30,
  "loraAdjustmentScale": 0.6
}

Output: The action typically returns a URL pointing to the generated image.

[
  "https://assets.cognitiveactions.com/invocations/669d827f-6c14-49bd-9a2b-fcfbb1c926ca/76e8026b-fc73-4129-b0b7-ef72f922b4cb.png"
]

Conceptual Usage Example (Python): Here's how you might use this action in a Python script:

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 = "0dc0cf58-5203-45f8-bde5-cbde92783129" # Action ID for Generate Toy Story Character Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "An animated TOK Elon Musk person, 90s animation",
    "guidanceScale": 7.5,
    "applyWatermark": False,
    "negativePrompt": "broken, distorted, ugly, two people",
    "promptStrength": 0.8,
    "refinementStyle": "expert_ensemble_refiner",
    "outputImageCount": 1,
    "schedulingMethod": "K_EULER",
    "highNoiseFraction": 0.9,
    "inferenceStepCount": 30,
    "loraAdjustmentScale": 0.6
}

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, replace the COGNITIVE_ACTIONS_API_KEY and endpoint with your actual credentials and URL. The action ID and input payload are structured according to the requirements outlined above.

Conclusion

The fofr/sdxl-toy-story-people Cognitive Actions offer a unique avenue for integrating imaginative image generation into your applications. By utilizing the action to generate Toy Story character images, developers can create engaging content that resonates with users. Consider exploring the potential applications of these actions in your projects, such as creating personalized experiences or enhancing visual storytelling. Happy coding!