Elevate Your Applications with Image Generation: A Guide to iamsml/shoes-sdxl Cognitive Actions

21 Apr 2025
Elevate Your Applications with Image Generation: A Guide to iamsml/shoes-sdxl Cognitive Actions

In the world of digital creativity, the ability to generate high-quality images based on textual prompts opens up a myriad of possibilities for developers. The iamsml/shoes-sdxl Cognitive Actions provide powerful functionality for image generation, including features like inpainting and style refinement. By leveraging these pre-built actions, developers can enhance their applications with advanced visual outputs tailored to specific needs.

Prerequisites

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

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Basic knowledge of sending HTTP requests and handling JSON data.
  • Familiarity with Python for implementing the provided code snippets.

To authenticate your requests, you will typically include your API key in the request headers.

Cognitive Actions Overview

Generate Image with Inpainting and Style Refinement

This action creates stunning images from a text prompt, providing advanced options for inpainting and style refinement. Whether you want to emphasize certain aspects of the image or refine its style, this action has you covered.

  • Category: Image Generation

Input

The action's input schema consists of several fields that guide the image creation process:

  • mask (string, optional): URI to the input mask for inpaint mode. Black areas will be preserved, while white areas will be inpainted.
  • seed (integer, optional): Random seed for reproducibility. Leave blank for a random seed.
  • image (string, optional): URI to the input image for 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, required): Text prompt guiding the image generation.
  • antiPrompt (string, optional): Text prompt to discourage specific features.
  • loraWeight (number, default: 0.6): Scaling factor for LoRA, between 0 and 1.
  • refineStyle (string, default: "no_refiner"): Style refinement options.
  • scheduleType (string, default: "K_EULER"): Scheduling algorithm for generation.
  • outputQuantity (integer, default: 1): Number of images to generate (1 to 4).
  • promptIntensity (number, default: 0.8): Strength of the prompt.
  • includeWatermark (boolean, default: true): Whether to add a watermark to the images.

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "a photo of @jordan1 basketball shoe, dark and gritty, highly detailed, retro-futuristic style, neon lighting, cyberpunk city in the background, art by wlop, greg rutkowski, and charlie bowater, 8 k resolution, ultra-realistic, octane render, unreal engine.",
  "antiPrompt": "ugly, ugly arms, ugly hands, ugly legs",
  "loraWeight": 0.7,
  "refineStyle": "no_refiner",
  "scheduleType": "K_EULER",
  "outputQuantity": 1,
  "promptIntensity": 0.8,
  "includeWatermark": true,
  "guidanceIntensity": 7.5,
  "highNoiseFraction": 0.8,
  "inferenceIterations": 50
}

Output

The action typically returns a link to the generated image. For example:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/3e970194-e652-4bba-b9da-5d6027be5755/38cc808a-0e82-4b87-ba0d-eba6c53be6f4.png"
]

Conceptual Usage Example (Python)

The following Python code snippet demonstrates how you can invoke the "Generate Image with Inpainting and Style Refinement" 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 = "5e24f2d6-5259-44bd-bc61-009a8150c38b"  # Action ID for Generate Image with Inpainting and Style Refinement

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "a photo of @jordan1 basketball shoe, dark and gritty, highly detailed, retro-futuristic style, neon lighting, cyberpunk city in the background, art by wlop, greg rutkowski, and charlie bowater, 8 k resolution, ultra-realistic, octane render, unreal engine.",
    "antiPrompt": "ugly, ugly arms, ugly hands, ugly legs",
    "loraWeight": 0.7,
    "refineStyle": "no_refiner",
    "scheduleType": "K_EULER",
    "outputQuantity": 1,
    "promptIntensity": 0.8,
    "includeWatermark": true,
    "guidanceIntensity": 7.5,
    "highNoiseFraction": 0.8,
    "inferenceIterations": 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 code, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id corresponds to the image generation action, and the payload is structured according to the requirements outlined above.

Conclusion

The iamsml/shoes-sdxl Cognitive Actions empower developers to generate high-quality images tailored to specific requirements effortlessly. By leveraging the capabilities of the "Generate Image with Inpainting and Style Refinement" action, you can enrich your applications with visually stunning content. Explore these actions further to discover new creative possibilities and enhance user experiences in your projects!