Enhance Your App with Image Generation and Inpainting Using siamakf/campfire-angelina-sdxl Actions

23 Apr 2025
Enhance Your App with Image Generation and Inpainting Using siamakf/campfire-angelina-sdxl Actions

In the ever-evolving world of technology, the ability to generate and manipulate images dynamically can set an application apart. The siamakf/campfire-angelina-sdxl API offers a powerful Cognitive Action specifically designed for image generation through inpainting techniques. This action allows developers to create images based on prompts, refine them according to specific parameters, and ensure quality control through various safety options. By leveraging this pre-built action, developers can enhance their applications with advanced image generation capabilities without needing extensive background in machine learning or image processing.

Prerequisites

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

  • An API key for the Cognitive Actions platform. This key will be used to authenticate your requests.
  • Familiarity with JSON format, as the input and output will be structured in JSON.
  • Basic understanding of how to make HTTP requests in your development environment.

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

Cognitive Actions Overview

Generate Image with Inpainting

The Generate Image with Inpainting action allows you to create images using inpainting techniques that can modify specific parts of an image based on your input parameters. This action is categorized under image-generation and provides configurable settings such as image dimensions, prompt strength, and various refinement methods.

Input

The input for this action is structured as follows:

{
  "mask": "string",
  "seed": "integer",
  "image": "string",
  "width": "integer",
  "height": "integer",
  "prompt": "string",
  "refine": "string",
  "scheduler": "string",
  "layeredScale": "number",
  "guidanceScale": "number",
  "applyWatermark": "boolean",
  "inferenceSteps": "integer",
  "negativePrompt": "string",
  "promptStrength": "number",
  "numberOfOutputs": "integer",
  "refinementSteps": "integer",
  "highNoiseFraction": "number",
  "alternativeWeights": "string",
  "disableSafetyChecker": "boolean"
}

Here’s a practical example of the input payload:

{
  "width": 1024,
  "height": 1024,
  "prompt": "cute fox expressing joy, animal crossing",
  "refine": "expert_ensemble_refiner",
  "scheduler": "K_EULER",
  "layeredScale": 0.6,
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "inferenceSteps": 75,
  "negativePrompt": "realistic",
  "promptStrength": 0.8,
  "numberOfOutputs": 4,
  "highNoiseFraction": 0.8
}

Output

Upon successful execution, the action will return an array of image URLs, which represent the generated images. Here’s an example of what the output might look like:

[
  "https://assets.cognitiveactions.com/invocations/6a2a13aa-5756-4391-80a0-2ddf07a18b3b/710aa067-2724-4930-a453-c969119a101d.png",
  "https://assets.cognitiveactions.com/invocations/6a2a13aa-5756-4391-80a0-2ddf07a18b3b/53287b8e-08dd-4615-852b-4d06be8c8a8f.png",
  "https://assets.cognitiveactions.com/invocations/6a2a13aa-5756-4391-80a0-2ddf07a18b3b/0ac599bd-fb4a-493e-a870-1833b6ac3ed3.png",
  "https://assets.cognitiveactions.com/invocations/6a2a13aa-5756-4391-80a0-2ddf07a18b3b/a0f6f5f9-0cd7-4fee-b263-fe9a37b4e8fe.png"
]

Conceptual Usage Example (Python)

Here’s a simple Python code snippet showcasing how to call the Generate Image with Inpainting action using a hypothetical Cognitive Actions endpoint:

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 = "6ce49a6f-eb84-4780-b1dd-55d1f8793871"  # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "cute fox expressing joy, animal crossing",
    "refine": "expert_ensemble_refiner",
    "scheduler": "K_EULER",
    "layeredScale": 0.6,
    "guidanceScale": 7.5,
    "applyWatermark": True,
    "inferenceSteps": 75,
    "negativePrompt": "realistic",
    "promptStrength": 0.8,
    "numberOfOutputs": 4,
    "highNoiseFraction": 0.8
}

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 action ID is specified for the image generation action, and the input payload is structured as required by the action.

Conclusion

Integrating the Generate Image with Inpainting action from the siamakf/campfire-angelina-sdxl API can significantly enhance your application's capabilities by enabling dynamic image creation and manipulation. With various parameters available for customization, you can tailor the generated images to meet specific needs. As you explore the potential of these Cognitive Actions, consider other use cases and additional features that can further enrich your applications. Happy coding!