Creating Stunning Images with Style Transfer using Cognitive Actions

22 Apr 2025
Creating Stunning Images with Style Transfer using Cognitive Actions

In the realm of digital creativity, the ability to generate stylized images has become increasingly accessible thanks to advanced technologies. The gabrielbarrientos99/arcane_jinx_ekko Cognitive Actions provide developers with powerful tools to create unique and personalized images using a combination of image-to-image transformation and inpainting techniques. This article will guide you through the capabilities of the Generate Image with Style Transfer action, how to integrate it into your applications, and the benefits it offers in generating high-quality, custom visuals.

Prerequisites

To get started with the Cognitive Actions, you'll need an API key for authentication. This key should be included in the request headers to allow access to the action. Additionally, ensure you have a working environment set up for making HTTP requests, such as Python with the requests library.

Cognitive Actions Overview

Generate Image with Style Transfer

The Generate Image with Style Transfer action allows you to create stylized images by applying various customizable parameters. This action supports different models optimized for varying inference step counts, enabling you to tailor the image generation process to your specific needs.

Input

The input for this action requires a prompt and can include several optional fields. Below is the schema and an example input.

Input Schema:

  • prompt (required): A description of the image to generate.
  • model: Choose between 'dev' (28 steps) or 'schnell' (4 steps).
  • image: Input image for transformation or inpainting.
  • mask: Image mask for inpainting; if provided, width and height are ignored.
  • aspectRatio: Sets the aspect ratio of the generated image.
  • width: Custom width if aspect ratio is set to custom.
  • height: Custom height if aspect ratio is set to custom.
  • megapixels: Approximate number of megapixels for the output.
  • outputFormat: Format for the output images (webp, jpg, png).
  • guidanceScale: Influences the diffusion process; lower values yield more realistic images.
  • numberOfOutputs: Number of images to generate.

Example Input:

{
  "model": "dev",
  "prompt": "A young female hybrid character, the son of JINX and EKKO. she has JINX's sharp, angular facial structure and intense, piercing gaze, combined with EKKO's glowing cyberpunk tattoos and a bold, commanding aura. His hair is strikingly white, like EKKO's, styled in a modern, windswept fashion that enhances his masculine features. His outfit blends JINX's sleek, tech-inspired design with EKKO's rugged, urban streetwear, creating a look that is both powerful and stylish. The character stands confidently in a neon-lit cyberpunk cityscape, exuding strength, charisma, and a hint of playful mischief that reflects his parents' contrasting yet harmonious traits.",
  "megapixels": "1",
  "aspectRatio": "9:16",
  "loraStrength": 1,
  "outputFormat": "jpg",
  "guidanceScale": 3,
  "outputQuality": 80,
  "enableFastMode": false,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "additionalLoraStrength": 1,
  "numberOfInferenceSteps": 30
}

Output

The action typically returns a URL to the generated image, allowing you to easily access the output.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/2318a992-243b-4ddb-afc3-772b67c660c2/d4a79fa4-7221-4e18-a61c-a83d44730a09.jpg"
]

Conceptual Usage Example (Python)

The following Python code demonstrates how to call the Generate Image with Style Transfer action:

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 = "9265a214-a0df-49be-a0cd-5b4d464900ee"  # Action ID for Generate Image with Style Transfer

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "A young female hybrid character, the son of JINX and EKKO. she has JINX's sharp, angular facial structure...",
    "megapixels": "1",
    "aspectRatio": "9:16",
    "loraStrength": 1,
    "outputFormat": "jpg",
    "guidanceScale": 3,
    "outputQuality": 80,
    "enableFastMode": False,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "additionalLoraStrength": 1,
    "numberOfInferenceSteps": 30
}

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 example, replace "YOUR_COGNITIVE_ACTIONS_API_KEY" with your actual API key. The action ID should match the Generate Image with Style Transfer action, and the payload must be structured to include all required fields as indicated.

Conclusion

The Generate Image with Style Transfer action from the gabrielbarrientos99/arcane_jinx_ekko Cognitive Actions provides an exciting opportunity for developers to create visually stunning, personalized images. With customizable parameters and high-quality output, integrating this action into your applications can enhance user experiences and expand creative possibilities. Explore the various use cases, from game design to digital art, and start crafting unique visuals today!