Enhance Your Creativity with Image Generation and Inpainting

27 Apr 2025
Enhance Your Creativity with Image Generation and Inpainting

In today's digital landscape, the ability to create and modify images efficiently is invaluable for developers across various industries. The "Ai Acdc" service offers a powerful Cognitive Action aimed at generating images using advanced inpainting techniques. This action not only streamlines the image creation process but also allows for extensive customization, enabling you to produce visually stunning results that align with your creative vision.

With features such as adjustable aspect ratios, customizable image dimensions, and multiple output formats, the Ai Acdc action empowers developers to generate images tailored to specific requirements. Common use cases include creating unique marketing materials, enhancing visual storytelling in applications, or generating art for games and virtual environments. By leveraging this action, developers can significantly reduce the time and effort spent on image manipulation while improving the quality of their visual content.

Prerequisites

To get started with Ai Acdc, you will need a Cognitive Actions API key and a basic understanding of making API calls.

Generate Image with Inpainting

This operation allows the generation of images using inpainting techniques. It offers customizable features like aspect ratio, width, and height for image generation. Models 'dev' and 'schnell' are available, each optimized for different inference steps, with 'schnell' supporting faster generation. Options include setting image quality, number of outputs, guidance scale, and applying LoRA modifications.

Input Requirements

The input for this action is structured as a JSON object, requiring at least a prompt to guide the image generation. Additional parameters include:

  • mask: A URI to an image mask for inpainting mode.
  • seed: An integer seed value for reproducibility.
  • image: A URI to an input image for image-to-image or inpainting modes.
  • width and height: Integers defining the dimensions of the generated image.
  • aspectRatio: Specifies the aspect ratio of the generated image.
  • outputFormat: The file format for output images (webp, jpg, png).
  • guidanceScale: A number adjusting the guidance strength during image diffusion.
  • numOutputs: The number of image outputs to generate.

Expected Output

The expected output is a URI pointing to the generated image, which can be accessed directly for use in applications.

Use Cases for this Specific Action

  • Marketing and Advertising: Create tailored images for campaigns that resonate with specific target audiences.
  • Game Development: Generate unique assets or backgrounds that enhance the gaming experience.
  • Content Creation: Develop original artwork for blogs, websites, or social media to engage users visually.
  • Prototyping: Quickly create visual prototypes for apps or products, allowing for faster iterations and feedback.
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 = "2091ed7d-55cd-4913-b0d0-50a0598efa05" # 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": "AIACDC  worn by a woman model ",
  "loraScale": 1,
  "numOutputs": 1,
  "aspectRatio": "4:5",
  "outputFormat": "png",
  "guidanceScale": 3.5,
  "outputQuality": 90,
  "extraLoraScale": 1,
  "inferenceModel": "dev",
  "promptStrength": 0.8,
  "numInferenceSteps": 28
}

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

The Ai Acdc Cognitive Action for image generation and inpainting presents a transformative tool for developers looking to enhance their creative workflows. By simplifying the image creation process and providing extensive customization options, this action enables developers to produce high-quality visuals efficiently. Whether you're working on marketing materials, game assets, or content for digital platforms, integrating Ai Acdc into your projects can lead to significant improvements in both productivity and creativity. Ready to take your images to the next level? Start exploring the possibilities with Ai Acdc today!