Create Stunning Images with Craisee4 Inpainting Actions

26 Apr 2025
Create Stunning Images with Craisee4 Inpainting Actions

In the ever-evolving world of digital content creation, having the ability to generate high-quality images quickly can significantly enhance your workflow. Craisee4 offers a powerful cognitive action that enables developers to generate images using inpainting techniques. This functionality not only simplifies the image creation process but also allows for extensive customization through various parameters such as dimensions, aspect ratios, and processing modes.

Imagine creating unique visuals for websites, marketing materials, or social media posts without the need for extensive graphic design skills. Whether you want to create promotional graphics, digital art, or even unique backgrounds, the inpainting capabilities of Craisee4 can save you time and effort while producing impressive results.

Prerequisites

To get started, you'll need access to the Craisee4 Cognitive Actions API key and a basic understanding of how to make API calls.

Generate Image with Inpainting

The Generate Image with Inpainting action is designed to produce high-quality images tailored to your specifications. This action is particularly useful for developers looking to integrate image generation capabilities into their applications or services.

Purpose

This action solves the problem of needing custom images by providing a straightforward way to generate them based on user-defined prompts and parameters. It harnesses the power of advanced inpainting models, allowing for creative flexibility and high-quality outputs.

Input Requirements

To use this action, you'll need to provide the following inputs:

  • prompt (string): A descriptive text that guides the image generation (e.g., "a art collage of christmas, CRAISEE").
  • outputCount (integer): Number of images to generate (default is 1, maximum is 4).
  • inferenceModel (string): Choose between "dev" or "schnell" for different processing efficiencies.
  • imageAspectRatio (string): Defines the aspect ratio of the generated image (e.g., "1:1").
  • imageOutputFormat (string): Format for the generated images, such as "webp", "jpg", or "png".
  • imageOutputQuality (integer): Sets the image quality from 0 (lowest) to 100 (highest).
  • additionalLoraScale (number): Adjusts the intensity of additional LoRA.
  • denoisingStepsCount (integer): Sets the number of denoising steps for image clarity.
  • imagePromptStrength (number): Defines how strongly the prompt influences the image.
  • loraApplicationScale (number): Specifies the intensity of the main LoRA.
  • diffusionGuidanceScale (number): Adjusts the realism of the generated images.

Expected Output

The expected output is a URL to the generated image, which will be in the specified format and of high quality. For example, a successful output might look like this:

  • https://assets.cognitiveactions.com/invocations/46d845de-556e-4b99-bc0d-3fac57cb50b1/cb537d00-fb3f-45be-a17d-9da6cb581593.webp

Use Cases for this Action

  • Marketing Materials: Quickly generate visuals for advertising campaigns, reducing dependence on graphic designers.
  • Social Media Content: Create engaging images tailored to specific themes or promotions for social media platforms.
  • Web Design: Produce unique backgrounds or illustrations for websites, enhancing the overall aesthetic without extensive design work.
  • Art Projects: Generate creative pieces for digital art projects, allowing artists to explore new concepts and styles easily.
import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "2aa06d37-7477-421d-9034-706e7fc1c3ce" # Action ID for: Generate Image with Inpainting

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "prompt": "a art collage of christmas, CRAISEE",
  "outputCount": 1,
  "inferenceModel": "dev",
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "imageOutputQuality": 90,
  "additionalLoraScale": 1,
  "denoisingStepsCount": 28,
  "imagePromptStrength": 0.8,
  "loraApplicationScale": 1,
  "diffusionGuidanceScale": 3.5
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    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 (non-JSON): {e.response.text}")
    print("------------------------------------------------")

Conclusion

With the image generation capabilities of Craisee4's inpainting action, developers can easily create high-quality, customized images for a variety of applications. The flexibility in input parameters allows for a wide range of creative possibilities, making it an invaluable tool for anyone looking to enhance their digital content.

Start integrating Craisee4 into your projects today and unlock the potential for stunning visual content creation!