Create Stunning AI-Generated Images with Inpainting Capabilities

26 Apr 2025
Create Stunning AI-Generated Images with Inpainting Capabilities

In the world of digital art and design, the ability to generate and manipulate images with precision is invaluable. The "Amy Tattoo Test 1" service provides developers with powerful Cognitive Actions that simplify and enhance the image generation process. Specifically, the Generate AI Image with Inpainting action allows for the creation of custom images by leveraging advanced AI techniques, including inpainting capabilities. This functionality enables users to fill in or alter specific parts of images based on their needs, making it an essential tool for artists, designers, and developers alike.

Imagine being able to create unique tattoo designs or artwork by simply inputting a text description, adjusting image dimensions, and selecting refinement styles. This service not only speeds up the creative process but also allows for a high degree of customization, ensuring that the generated images align perfectly with the user's vision. Whether you’re designing for a client or exploring creative ideas, this action can streamline your workflow and elevate your projects.

Prerequisites

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

Generate AI Image with Inpainting

The Generate AI Image with Inpainting action is designed to create AI-generated images while offering inpainting capabilities. This action solves the problem of generating high-quality images from text prompts, while also allowing users to specify which parts of the image should be preserved or altered.

Input Requirements

To utilize this action, you need to provide a variety of parameters:

  • Prompt: A detailed description guiding the image generation (e.g., "A TOK tattoo drawing style of California poppies on Mount Tam").
  • Image: The URI of the input image for img2img or inpaint mode.
  • Mask: A URI pointing to an input mask for inpainting.
  • Width & Height: Dimensions of the output image, defaulting to 1024 pixels.
  • Refinement Method: Choose from options like no refiner or expert ensemble refiner.
  • Additional settings: Such as LoRA scaling, number of outputs, guidance scale, and more.

Expected Output

The action returns one or more generated images as URIs. For example:

Use Cases for this Specific Action

  • Tattoo Design: Artists can create intricate tattoo designs by combining different elements and styles from prompts.
  • Creative Projects: Designers can rapidly generate concepts for marketing materials or branding.
  • Image Restoration: Use the inpainting feature to fill in missing or damaged areas of existing images.
  • Artistic Exploration: Developers can experiment with various prompts and settings to discover new styles and ideas.
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 = "007d3641-b2e6-47de-85fa-d4a099e01e3b" # Action ID for: Generate AI 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 = {
  "width": 1024,
  "height": 1024,
  "prompt": "A TOK tattoo drawing style of california poppies on mount tam",
  "refine": "no_refiner",
  "loraScale": 0.6,
  "scheduler": "K_EULER",
  "enableWatermark": true,
  "numberOfOutputs": 2,
  "promptIntensity": 0.8,
  "highNoiseFraction": 0.8,
  "negativeInputPrompt": "",
  "guidanceScalingFactor": 7.5,
  "numberOfInferenceSteps": 25
}

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 Generate AI Image with Inpainting action offers a powerful solution for developers looking to enhance their creative processes. By facilitating the generation of custom images and providing inpainting capabilities, this action opens up a world of possibilities for artists and designers. Whether you're creating unique tattoo designs or exploring innovative visual concepts, this tool can significantly streamline your workflow and inspire your creativity. To begin, explore the API documentation and start integrating this action into your projects today!