Create Stunning Studio Ghibli-Inspired Images with Cognitive Actions

22 Apr 2025
Create Stunning Studio Ghibli-Inspired Images with Cognitive Actions

The karanchawla/studio-ghibli Cognitive Actions offer developers an exciting opportunity to generate mesmerizing images inspired by the iconic style of Studio Ghibli. By leveraging the Public SDXL model, these pre-built Cognitive Actions enable you to create unique visuals with features like inpainting, prompt-based guidance, and quality refinement options. In this article, we'll explore how to integrate these actions into your applications, empowering you to craft captivating imagery effortlessly.

Prerequisites

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

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Basic knowledge of JSON and how to structure it for API calls.

To authenticate your requests, you will typically pass your API key in the headers of your HTTP requests. This method ensures secure and authorized access to the Cognitive Actions.

Cognitive Actions Overview

Generate Studio Ghibli Style Image

The Generate Studio Ghibli Style Image action allows you to create images that embody the enchanting aesthetic of Studio Ghibli films. You can utilize various parameters to customize the output, including prompts, dimensions, and refinement styles.

Input

The action requires a structured JSON object as input, which may include the following fields:

  • prompt (string): Text input describing the intended content of the image. Default: "An astronaut riding a rainbow unicorn."
  • width (integer): Output image width in pixels. Default: 1024.
  • height (integer): Output image height in pixels. Default: 1024.
  • refine (string): Selection of refinement style. Default: "no_refiner."
  • guidanceScale (number): Multiplier for classifier-free guidance. Default: 7.5.
  • numberOfOutputs (integer): Number of images to generate. Default: 1.
  • applyWatermark (boolean): Flag to apply a watermark. Default: true.
  • numberOfInferenceSteps (integer): Total steps for image denoising and refinement. Default: 50.

Here is an example of a JSON payload you might send:

{
  "width": 1024,
  "height": 1024,
  "prompt": "In the style of Studio Ghibli, an old warm house with lush indoor plants and a burning fireplace and turkish carpets at night, a kid on the floor reading a book, snow visible outside through a large window",
  "refine": "no_refiner",
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "numberOfOutputs": 1,
  "numberOfInferenceSteps": 50
}

Output

Upon successful execution, the action returns a URL pointing to the generated image. For example:

[
  "https://assets.cognitiveactions.com/invocations/52ff6916-4952-4c20-a79b-b20e24f8fdf9/a44e435b-57dd-4146-a3c2-3df74ca1a176.png"
]

Conceptual Usage Example (Python)

Here’s how you might call this action using 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 = "cdeb3b91-eee1-4981-9590-bfe1613ed855" # Action ID for Generate Studio Ghibli Style Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "In the style of Studio Ghibli, an old warm house with lush indoor plants and a burning fireplace and turkish carpets at night, a kid on the floor reading a book, snow visible outside through a large window",
    "refine": "no_refiner",
    "guidanceScale": 7.5,
    "applyWatermark": True,
    "numberOfOutputs": 1,
    "numberOfInferenceSteps": 50
}

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 snippet, replace "YOUR_COGNITIVE_ACTIONS_API_KEY" with your actual API key. The action_id corresponds to the Generate Studio Ghibli Style Image action. The input payload follows the schema discussed earlier, ensuring you structure your request correctly.

Conclusion

The karanchawla/studio-ghibli Cognitive Actions provide a powerful way to generate unique Studio Ghibli-inspired images programmatically. By utilizing the various parameters, you can customize your images to suit your creative vision. Explore the potential applications of these actions in your projects, whether for artistic endeavors, game design, or content creation. Start integrating these actions today and bring a touch of magic to your applications!