Unleash Creativity with Image Generation: Integrating sinazar/campfire-fox3 Cognitive Actions

25 Apr 2025
Unleash Creativity with Image Generation: Integrating sinazar/campfire-fox3 Cognitive Actions

In the realm of image processing, the sinazar/campfire-fox3 API offers powerful Cognitive Actions that allow developers to generate and refine images in innovative ways. These pre-built actions simplify the complex task of image manipulation, enabling you to create visually stunning outputs with minimal effort. This article will guide you through the integration of the Generate Inpainted Images action, its capabilities, and how to use it effectively in your applications.

Prerequisites

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

  • An API key for the Cognitive Actions platform.
  • Basic understanding of JSON format for constructing requests.
  • Familiarity with making HTTP requests, particularly POST requests.

For authentication, you typically pass your API key in the headers of your requests.

Cognitive Actions Overview

Generate Inpainted Images

The Generate Inpainted Images action allows you to create and refine images based on a provided mask, input image, and descriptive prompts. This action supports various refinement techniques and offers customization options for output dimensions, noise control, and more.

Category: Image Processing

Input

The input for this action requires a JSON object with the following fields:

  • mask (string, required): URI of the input mask. Black areas are preserved, white areas are inpainted.
  • seed (integer, optional): Random seed for reproducibility.
  • image (string, required): URI of the input image.
  • width (integer, default: 1024): Width of the output image in pixels.
  • height (integer, default: 1024): Height of the output image in pixels.
  • prompt (string, default: "An astronaut riding a rainbow unicorn"): Text prompt guiding image generation.
  • refine (string, default: "no_refiner"): Style of refinement to apply.
  • scheduler (string, default: "K_EULER"): Type of scheduler for the denoising process.
  • guidanceScale (number, default: 7.5): Scale for classifier-free guidance (1 to 50).
  • applyWatermark (boolean, default: true): Option to apply a watermark to images.
  • negativePrompt (string, default: ""): Prompt to guide what to avoid in generation.
  • promptStrength (number, default: 0.8): Strength of the prompt (0 to 1).
  • numberOfOutputs (integer, default: 1): Number of images to generate (1 to 4).
  • highNoiseFraction (number, default: 0.8): Fraction of noise for refinement.
  • loraAdditiveScale (number, default: 0.6): Addition scale for LoRA.
  • numberOfInferenceSteps (integer, default: 50): Total denoising steps during generation.

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "a photo of TOK smiling and being happy on a sunny day, fox, animal crossing",
  "refine": "expert_ensemble_refiner",
  "scheduler": "K_EULER",
  "guidanceScale": 7.5,
  "applyWatermark": false,
  "negativePrompt": "realistic, multiple TOK",
  "promptStrength": 0.8,
  "numberOfOutputs": 4,
  "highNoiseFraction": 0.8,
  "loraAdditiveScale": 0.6,
  "numberOfInferenceSteps": 75
}

Output

The output of this action is typically a list of URIs pointing to the generated images. For example:

[
  "https://assets.cognitiveactions.com/invocations/01e02b8b-9f45-4316-8933-da7113d3bf1b/edd44b05-6eb7-400e-846f-c6c592769b6e.png",
  "https://assets.cognitiveactions.com/invocations/01e02b8b-9f45-4316-8933-da7113d3bf1b/25e40fd3-0611-4e67-ab9a-3258f5b346ba.png",
  "https://assets.cognitiveactions.com/invocations/01e02b8b-9f45-4316-8933-da7113d3bf1b/73bc5f99-8d97-4457-8ac3-0d667ff399f7.png",
  "https://assets.cognitiveactions.com/invocations/01e02b8b-9f45-4316-8933-da7113d3bf1b/55503da7-04af-4ca9-b4e2-c23f699a3ebd.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet to demonstrate how you might invoke this 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 = "1f90ec0a-6111-46d7-93fa-9a3cc7a57e15" # Action ID for Generate Inpainted Images

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "a photo of TOK smiling and being happy on a sunny day, fox, animal crossing",
    "refine": "expert_ensemble_refiner",
    "scheduler": "K_EULER",
    "guidanceScale": 7.5,
    "applyWatermark": False,
    "negativePrompt": "realistic, multiple TOK",
    "promptStrength": 0.8,
    "numberOfOutputs": 4,
    "highNoiseFraction": 0.8,
    "loraAdditiveScale": 0.6,
    "numberOfInferenceSteps": 75
}

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 for generating inpainted images is specified, and the input payload is constructed according to the action's schema. The response is processed to display the generated image URIs.

Conclusion

The Generate Inpainted Images action from the sinazar/campfire-fox3 API empowers developers to create and manipulate images with ease. By leveraging customizable parameters and advanced refinement techniques, you can enhance your applications with stunning visual content. Start experimenting with these Cognitive Actions today to unlock new creative possibilities in your projects!