Create Stunning Images with Ai Jo's Inpainting Action

25 Apr 2025
Create Stunning Images with Ai Jo's Inpainting Action

In the world of digital content creation, the ability to generate high-quality images quickly and efficiently is a game-changer. Ai Jo offers a powerful Cognitive Action called "Generate Image with Inpainting," designed specifically for developers looking to enhance their applications with sophisticated image generation capabilities. This action utilizes advanced inpainting techniques, allowing you to create images based on detailed prompts while offering customizable parameters for optimal control over the output.

Whether you're building an art generation platform, designing marketing materials, or creating unique visuals for social media, Ai Jo's inpainting action simplifies the image creation process. With its ability to generate images swiftly without sacrificing quality, developers can focus more on creativity and less on the technical complexities of image generation.

Prerequisites

To get started with Ai Jo, you'll need a 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 create images based on a provided prompt. This action solves the problem of needing unique visual content by allowing you to specify detailed descriptions that the model uses to produce images, making it ideal for creative projects.

Input Requirements

The input for this action is structured as an object that includes several parameters:

  • prompt: A detailed description of the image you want to generate, which plays a crucial role in the output.
  • mask: An optional URI of an image mask to define specific areas for inpainting.
  • image: An optional URI of an existing image for image-to-image generation.
  • model: Select either the 'dev' or 'schnell' model based on your performance needs.
  • aspectRatio: Choose from predefined ratios or set a custom width and height.
  • outputCount: Specify the number of images you want to generate.
  • outputFormat: Choose the desired format for the output images (webp, jpg, png).
  • guidanceScale: Adjust the guidance scale to influence the realism of the generated images.

Expected Output

The expected output is a URL linking to the generated image(s). For example, the output might look like this:

  • https://assets.cognitiveactions.com/invocations/97a5a50e-01ff-4a90-89fb-d150d53e5f08/0c575ae8-5b11-4b20-bea9-2600d2d283ec.png

Use Cases for this Specific Action

  • Art and Design: Artists and designers can use this action to generate unique artwork based on specific themes or styles.
  • Marketing: Marketers can quickly create engaging visuals tailored to specific campaigns, enhancing their promotional materials.
  • Social Media Content: Social media managers can generate eye-catching images that resonate with their audience, saving time while maintaining creativity.
  • Game Development: Game developers can create unique assets for characters or environments based on descriptive prompts, streamlining the asset creation process.
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 = "9997d00d-223a-4e36-8c90-ed5a8156a676" # 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 = {
  "model": "dev",
  "prompt": "Aijo, a young singer wearing black rimmed glasses with a warm, golden-brown skin tone and short, spiky black hair, stands confidently on a dimly lit Colombian concert stage, bathed in the moody, cinematic lighting of a Wong Kar-wai film. Soft, diffused light from a warm-toned LED panel (5600K) positioned at a 45-degree angle to his left illuminates his determined expression, accentuating the contours of his face. Aijo's eyes, cast downward, shine with intensity as he belts out a powerful melody, his voice echoing through the crowded venue. The camera, positioned at a 1.2 front view, captures the dynamic energy of the performance. A shallow depth of field (f/2.8) blurs the surrounding audience, focusing attention on Aijo's charismatic stage presence. Subtle film grain and a warm color grade (Kodak 35mm film stock aesthetic) enhance the moody, passionate atmosphere, with warm shadows and highlights.",
  "aspectRatio": "1:1",
  "outputCount": 1,
  "outputFormat": "png",
  "guidanceScale": 3.5,
  "outputQuality": 100,
  "promptStrength": 0.8,
  "loraWeightScale": 1,
  "additionalLoraScale": 1,
  "inferenceStepsCount": 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

Ai Jo's "Generate Image with Inpainting" action provides developers with the tools needed to create stunning, customized images efficiently. By leveraging this action, you can enhance your applications with unique visual content, streamline your creative processes, and ultimately deliver better value to your users. Start experimenting with Ai Jo today to unlock the full potential of image generation in your projects!