Create Stunning Images with sinazar/campfire-deer3-may9 Cognitive Actions

22 Apr 2025
Create Stunning Images with sinazar/campfire-deer3-may9 Cognitive Actions

In the world of computer vision and image generation, the sinazar/campfire-deer3-may9 API offers a powerful set of Cognitive Actions that allow developers to create stunning, customized images with ease. Among these actions, the ability to generate inpainted images stands out, enabling users to blend creativity with technology by refining images based on specific prompts and parameters. This blog post will guide you through the capabilities of this action and how to integrate it into your applications seamlessly.

Prerequisites

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

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of making HTTP requests and handling JSON data.
  • A development environment set up for making API calls (e.g., Python with the requests library).

Conceptually, you will authenticate your requests by passing the API key in the headers.

Cognitive Actions Overview

Generate Inpainted Images

The Generate Inpainted Images action allows you to create refined images by combining img2img and inpainting modes. You can specify various parameters like masks, dimensions, and prompts, giving you control over the output's style, scheduler, guidance, and strength settings.

Input

The input schema for this action is a composite request with the following fields:

  • mask (string): URI of the input mask for inpainting mode. Black areas will be retained, and white areas will be inpainted.
  • seed (integer, optional): Random seed for deterministic outputs. Leave blank for a randomized seed.
  • image (string): URI of the input image for img2img or inpaint mode processing.
  • width (integer): Output image width (default: 1024).
  • height (integer): Output image height (default: 1024).
  • prompt (string): Text prompt guiding the image generation process (default example: "An astronaut riding a rainbow unicorn").
  • loraWeights (string, optional): LoRA weights for model guidance.
  • guidanceScale (number): Intensity of classifier-free guidance (default: 7.5).
  • schedulerType (string): Scheduler algorithm for image generation (default: "K_EULER").
  • applyWatermark (boolean): Whether to apply a watermark (default: true).
  • denoisingSteps (integer): Number of denoising steps during generation (default: 50).
  • negativePrompt (string, optional): Elements to exclude in the image generation.
  • promptStrength (number): Influence strength of the prompt (default: 0.8).
  • refinementSteps (integer, optional): Refinement steps for the base image refiner.
  • refinementStyle (string): Style of refinement during generation (default: "no_refiner").
  • outputImageCount (integer): Number of images to generate (default: 1, max: 4).
  • highNoiseFraction (number, optional): Noise fraction for using the expert ensemble refiner.
  • loraAdditiveScale (number, optional): Scale for the LoRA model contribution.
  • disableSafetyChecker (boolean): Disable safety checker for generated images (default: false).
Example Input

Here’s a sample JSON payload for invoking this action:

{
  "width": 1024,
  "height": 1024,
  "prompt": "A photo of TOK running around in the field, animal crossing",
  "guidanceScale": 7.5,
  "schedulerType": "K_EULER",
  "applyWatermark": false,
  "denoisingSteps": 75,
  "negativePrompt": "realistic",
  "promptStrength": 0.8,
  "refinementStyle": "expert_ensemble_refiner",
  "outputImageCount": 4,
  "highNoiseFraction": 0.8,
  "loraAdditiveScale": 0.6
}

Output

The output from this action typically consists of an array of URLs pointing to the generated images. For example:

[
  "https://assets.cognitiveactions.com/invocations/6f4b6982-2673-4805-812d-1c6ea85846b9/f7fbac86-1e7b-4f19-9d01-bc02e33db955.png",
  "https://assets.cognitiveactions.com/invocations/6f4b6982-2673-4805-812d-1c6ea85846b9/f52a9d0b-7e0f-409a-a98a-9e15de9e3644.png",
  "https://assets.cognitiveactions.com/invocations/6f4b6982-2673-4805-812d-1c6ea85846b9/49395c59-7152-423a-b93f-c5f4129eb870.png"
]

Conceptual Usage Example (Python)

Here’s how you might structure your API call using Python:

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 = "8d5efcd6-3f22-4d8e-a327-b43e4f91bbe2" # 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 running around in the field, animal crossing",
    "guidanceScale": 7.5,
    "schedulerType": "K_EULER",
    "applyWatermark": False,
    "denoisingSteps": 75,
    "negativePrompt": "realistic",
    "promptStrength": 0.8,
    "refinementStyle": "expert_ensemble_refiner",
    "outputImageCount": 4,
    "highNoiseFraction": 0.8,
    "loraAdditiveScale": 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}
    )
    response.raise_for_status()  # Raise an exception for bad status codes

    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 example, replace "YOUR_COGNITIVE_ACTIONS_API_KEY" with your actual API key. The endpoint and structure are illustrative, focusing on how to gather the input data and send it as a JSON payload.

Conclusion

The sinazar/campfire-deer3-may9 Cognitive Actions offer developers a robust solution for generating high-quality images through the Generate Inpainted Images action. By leveraging the specified parameters, you can create customized outputs tailored to your needs. Whether you're building an application for art, marketing, or any creative project, these actions provide a powerful toolset to enhance your workflows. Start experimenting with these capabilities today and unlock new creative possibilities!