Elevate Image Generation with jschoormans/zara-striped-shirt Cognitive Actions

24 Apr 2025
Elevate Image Generation with jschoormans/zara-striped-shirt Cognitive Actions

In the ever-evolving landscape of image processing, the jschoormans/zara-striped-shirt Cognitive Actions empower developers to create stunning visuals using advanced techniques like inpainting and img2img transformations. With these pre-built actions, you can generate new images efficiently, refine outputs with powerful algorithms, and even add watermarks for identification, all while minimizing the complexity of image manipulation tasks.

Prerequisites

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

  • An API key for the Cognitive Actions platform, which will be used for authentication when making requests.
  • Basic understanding of JSON structure as you'll be crafting JSON payloads for API calls.
  • Familiarity with Python for testing and implementing these actions.

Authentication typically involves passing your API key in the headers of your requests, allowing for secure access to the action endpoints.

Cognitive Actions Overview

Generate Inpainted Images

The Generate Inpainted Images action is designed to create new images by performing inpainting and img2img transformations based on a provided image and mask. This action allows you to refine the output using specific algorithms and includes options for watermarking.

Input

The action requires a structured input as defined in the schema:

{
  "mask": "uri_to_input_mask",
  "seed": 123,
  "image": "uri_to_input_image",
  "width": 1024,
  "height": 1024,
  "prompt": "a person wearing a TOK shirt",
  "refineStyle": "no_refiner",
  "guidanceScale": 7.5,
  "noiseFraction": 0.8,
  "applyWatermark": true,
  "negativePrompt": "",
  "promptStrength": 0.8,
  "refinementSteps": 10,
  "outputImageCount": 1,
  "processScheduler": "K_EULER",
  "additionalWeights": "uri_to_additional_weights",
  "numInferenceSteps": 50,
  "layerScalingFactor": 0.6,
  "safetyCheckDisabled": false
}

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "a person wearing a TOK shirt",
  "refineStyle": "no_refiner",
  "guidanceScale": 7.5,
  "noiseFraction": 0.8,
  "applyWatermark": true,
  "promptStrength": 0.8,
  "outputImageCount": 1,
  "processScheduler": "K_EULER",
  "numInferenceSteps": 50,
  "layerScalingFactor": 0.6
}

Output

Upon successful execution, the action returns an array of generated images. Each image is represented by a URI linking to the generated output.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/57225d1e-1d22-4645-be3c-fc000b86ae59/f9dc9719-6dd4-4b58-8862-b13e6560c1e9.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how to call the Cognitive Actions execution endpoint for generating inpainted images:

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 = "a4946648-8342-47f3-aa82-0e6305f45ea9"  # Action ID for Generate Inpainted Images

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "a person wearing a TOK shirt",
    "refineStyle": "no_refiner",
    "guidanceScale": 7.5,
    "noiseFraction": 0.8,
    "applyWatermark": True,
    "promptStrength": 0.8,
    "outputImageCount": 1,
    "processScheduler": "K_EULER",
    "numInferenceSteps": 50,
    "layerScalingFactor": 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 "YOUR_COGNITIVE_ACTIONS_API_KEY" with your actual API key. The payload variable is structured according to the action's specifications, ensuring that all necessary parameters are included.

Conclusion

The jschoormans/zara-striped-shirt Cognitive Actions offer a powerful set of tools for image generation and manipulation. By leveraging the Generate Inpainted Images action, developers can produce high-quality images that meet specific requirements, all while applying advanced techniques for image refinement. As you explore these actions further, consider the numerous applications in creative projects, content generation, and more. Happy coding!