Enhance Your Applications with Image Generation Using chigozienri/ip_adapter-sdxl-controlnet-canny

21 Apr 2025
Enhance Your Applications with Image Generation Using chigozienri/ip_adapter-sdxl-controlnet-canny

In today’s digital landscape, generating images programmatically can unlock exciting possibilities for developers. The chigozienri/ip_adapter-sdxl-controlnet-canny spec provides a powerful set of Cognitive Actions designed for image generation using ControlNet conditioning. These pre-built actions enable the creation of detailed images based on input parameters, allowing developers to enhance their applications with sophisticated image processing capabilities.

Prerequisites

Before you can start leveraging these Cognitive Actions, make sure you have the following:

  • An API key for the Cognitive Actions platform.
  • Familiarity with making HTTP requests and handling JSON data.

Authentication typically involves passing your API key in the request headers, allowing you to access the Cognitive Actions service securely.

Cognitive Actions Overview

Generate Image with ControlNet

Description: This action generates images based on a provided input image and ControlNet conditioning. It allows for customizable prompts and settings, enhancing the output through denoising and influence scaling.

Category: Image Generation

Input: The input for this action is defined by the following schema:

  • controlnetInput (string, required): URI of the ControlNet edges used for conditioning the generation process.
  • image (string, required): URI of the input image used for generation.
  • seed (integer, optional): Random seed used for generation. Leave blank for a random value.
  • scale (number, optional): Determines the influence of the input image on the output (default: 0.6, range: 0 to 1).
  • prompt (string, optional): Text prompt to guide the generation (default: empty string).
  • negativePrompt (string, optional): Text prompt specifying undesired elements in the generation (default: empty string).
  • numberOfOutputs (integer, optional): Specifies the number of images to generate (default: 1, range: 1 to 4).
  • numberOfInferenceSteps (integer, optional): Specifies the number of denoising steps (default: 30, range: 1 to 500).
  • controlnetConditioningScale (number, optional): Determines the extent of ControlNet conditioning (default: 0.6, range: 0 to 1).

Example Input:

{
  "image": "https://replicate.delivery/pbxt/Jr0saWsII5YZUO1SzaP7CgbZ441UNKcmQWFY2VtL9x5qe2Ur/statue.png",
  "scale": 0.6,
  "prompt": "",
  "negativePrompt": "",
  "controlnetInput": "https://replicate.delivery/pbxt/Jr0saVLgswCZFDKGmVBs2T1RB0xtcrXQRQk44lXwLxIfa08S/out_women_bw.png",
  "numberOfOutputs": 1,
  "numberOfInferenceSteps": 30,
  "controlnetConditioningScale": 0.6
}

Output: The action typically returns a list of URIs pointing to the generated images. Here’s an example output:

[
  "https://assets.cognitiveactions.com/invocations/cd833376-6a78-48b5-91cb-683f8b6945fe/5be8a271-f62a-444a-b5ac-8e05b343f8f6.png"
]

Conceptual Usage Example (Python): Below is a conceptual Python snippet demonstrating how to execute this action using the Cognitive Actions API.

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 = "da6e5641-fc0f-47ea-b5dd-393a60f2c455"  # Action ID for Generate Image with ControlNet

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://replicate.delivery/pbxt/Jr0saWsII5YZUO1SzaP7CgbZ441UNKcmQWFY2VtL9x5qe2Ur/statue.png",
    "scale": 0.6,
    "prompt": "",
    "negativePrompt": "",
    "controlnetInput": "https://replicate.delivery/pbxt/Jr0saVLgswCZFDKGmVBs2T1RB0xtcrXQRQk44lXwLxIfa08S/out_women_bw.png",
    "numberOfOutputs": 1,
    "numberOfInferenceSteps": 30,
    "controlnetConditioningScale": 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 constructs the input JSON based on the schema requirements. The action ID is specified, and the request sends this payload to the API.

Conclusion

The Generate Image with ControlNet action provides developers with an innovative tool for image generation, enabling detailed customization and control over the output. By leveraging these Cognitive Actions, you can enrich your applications with advanced image processing capabilities, opening up a world of creative possibilities. Explore different prompts and settings to see the diverse range of outputs you can generate!