Create Stunning Stylized Images with the jamonete2ia/prueba02 Cognitive Actions

24 Apr 2025
Create Stunning Stylized Images with the jamonete2ia/prueba02 Cognitive Actions

In the realm of AI-driven creativity, the jamonete2ia/prueba02 spec introduces powerful Cognitive Actions designed to generate stunning and stylized images. These pre-built actions enhance your applications by allowing developers to leverage image generation capabilities with customizable parameters. From inpainting to aspect ratios, these actions open up a world of creative possibilities.

Prerequisites

Before diving into the use of Cognitive Actions, ensure you have the following in place:

  • An API key for the Cognitive Actions platform, which will authenticate your requests.
  • Basic familiarity with making HTTP requests using libraries such as requests in Python.
  • A development environment set up for testing API calls.

When making requests, you'll typically pass your API key in the headers of your requests to authenticate your actions.

Cognitive Actions Overview

Generate Stylized Image

The Generate Stylized Image action creates stylized images using either image-to-image or inpainting modes. This action provides extensive customization options, allowing you to specify parameters like masks, seeds, dimensions, models, and output formats.

Input

The input schema for this action is defined as follows:

  • prompt (string, required): A detailed description of the image you want to generate.
  • mask (string, optional): An image mask for inpainting mode.
  • seed (integer, optional): Random seed for reproducible results.
  • image (string, optional): Input image used for transformation.
  • model (string, optional): Selects the inference model (dev or schnell).
  • width (integer, optional): Width of the generated image (active only with custom aspect ratio).
  • height (integer, optional): Height of the generated image (active only with custom aspect ratio).
  • fastMode (boolean, optional): Run predictions optimized for speed.
  • aspectRatio (string, optional): Specify the aspect ratio (default is 1:1).
  • outputFormat (string, optional): Format of the output images (default is webp).
  • guidanceScale (number, optional): Scale for the diffusion process.
  • numberOfOutputs (integer, optional): Number of outputs to generate.

Here’s an example of the JSON payload needed to invoke this action:

{
  "model": "dev",
  "prompt": "\"A high-quality portrait of a TOKFUT with a Modern Mullet, maintaining the same pose, facial expression, and lighting in each image. The background should be neutral and minimalistic to emphasize the hairstyle. Photorealistic, detailed hair texture, professional studio lighting.\"",
  "fastMode": false,
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3,
  "mainLoraScale": 1,
  "outputQuality": 80,
  "imageMegapixels": "1",
  "numberOfOutputs": 1,
  "additionalLoraScale": 1,
  "imagePromptStrength": 0.8,
  "numberOfInferenceSteps": 28
}

Output

Upon successful execution, the action typically returns a URL pointing to the generated image. Here’s an example of what the output might look like:

[
  "https://assets.cognitiveactions.com/invocations/79b56aa7-44d2-4a15-9382-91ae773223ee/ce5582c8-ba2e-43b1-9192-cf68a227bf2e.webp"
]

Conceptual Usage Example (Python)

To illustrate how developers can utilize this action in their applications, here’s a conceptual Python code snippet:

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 = "b05254d2-b560-4471-8c1f-84847db81070"  # Action ID for Generate Stylized Image

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "\"A high-quality portrait of a TOKFUT with a Modern Mullet, maintaining the same pose, facial expression, and lighting in each image. The background should be neutral and minimalistic to emphasize the hairstyle. Photorealistic, detailed hair texture, professional studio lighting.\"",
    "fastMode": False,
    "aspectRatio": "1:1",
    "outputFormat": "webp",
    "guidanceScale": 3,
    "mainLoraScale": 1,
    "outputQuality": 80,
    "imageMegapixels": "1",
    "numberOfOutputs": 1,
    "additionalLoraScale": 1,
    "imagePromptStrength": 0.8,
    "numberOfInferenceSteps": 28
}

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 placeholder API key and endpoint URL with your actual credentials. The action_id is set to the specific ID for generating stylized images. The input payload is structured to include all necessary parameters for the action.

Conclusion

The jamonete2ia/prueba02 Cognitive Actions provide developers with a versatile toolset for generating stylized images, allowing for extensive customization and control over the output. Whether you're creating art, enhancing visual content, or experimenting with AI-driven creativity, these actions can significantly enhance your application’s capabilities. Start integrating these actions today and unlock a new realm of creative potential!