Create Stunning Custom Images with Aquaaibase

27 Apr 2025
Create Stunning Custom Images with Aquaaibase

Aquaaibase offers a powerful suite of Cognitive Actions designed for developers seeking to enhance their applications with advanced image generation capabilities. Among these actions, the ability to generate custom images through inpainting and image-to-image transformation stands out. This feature not only simplifies the process of creating high-quality images but also allows for significant customization, enabling developers to achieve exactly the visual results they desire.

Imagine the possibilities: whether you're building a creative application, designing marketing materials, or enhancing user-generated content, the ability to craft unique images tailored to specific prompts can set your project apart. By leveraging Aquaaibase's image generation capabilities, you can save time and resources while delivering visually stunning outputs.

Prerequisites

To get started with Aquaaibase's Cognitive Actions, you'll need an API key and a basic understanding of making API calls.

Generate Custom Image Inpaint

The "Generate Custom Image Inpaint" action allows you to create custom images by using advanced image-to-image transformation and inpainting techniques. This operation supports various refinements such as HDR enhancement, noise control, and prompt guidance to achieve high-quality outputs.

Input Requirements

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

  • Mask: A URI of the input mask for inpainting mode, specifying which areas to preserve (black) and which to inpaint (white).
  • Image: A URI of the input image for image-to-image or inpainting mode.
  • Width & Height: Dimensions for the output image in pixels (default is 1024x1024).
  • Prompt: A text description guiding the generation process.
  • Strength: The denoising strength when img2img mode is active, influencing how much of the input image is preserved.
  • Num Outputs: The number of images to generate (1 to 4).
  • Refine Style: Specifies the refinement style to apply.

Expected Output

The expected output is a URI link to the generated image, which will reflect the specifications provided in the input.

Use Cases for this Specific Action

  • Creative Projects: Designers can utilize this action to generate unique artwork based on specific themes or ideas, enhancing their creative workflow.
  • Marketing Collateral: Marketers can create tailored visuals for campaigns, ensuring that the imagery aligns perfectly with their messaging.
  • Game Development: Game developers can generate character designs or environment art that fits the narrative of their game, enriching the player's experience.
  • Content Creation: Content creators can produce high-quality images for blogs, social media, or other platforms, attracting more engagement from their audience.
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 = "df8243bd-3401-40dc-b443-b7e0652fffd0" # Action ID for: Generate Custom Image Inpaint

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "width": 640,
  "height": 840,
  "prompt": "The woman in the photo is wearing a blue dress and standing in a white room. She looks elegant and sophisticated, with her posture and outfit drawing attention. The white room serves as a simple and clean background for her attire.The lighting is bright and natural, realist detail, ue5, detailed character expressions, amazing quality, wallpaper, analog film grain. one person, 8k. In the style of EveningDressDF",
  "refineStyle": "base_image_refiner",
  "schedulerType": "K_EULER_ANCESTRAL",
  "applyWatermark": false,
  "negativePrompt": "cropped face, cover face, cover visage, mutated hands, bad anatomy, bad hands, three hands, three legs, bad arms,(missing legs), missing arms, poorly drawn face, bad face, fused face, cloned face, worst face, three crus, extra crus, fused crus, worst feet, three feet, fused feet, fused thigh, three thigh, fused thigh, extra thigh, worst thigh, missing fingers, extra fingers, ugly fingers, long fingers, horn, extra eyes, huge eyes, 2girl, amputation, disconnected limbs, cartoon, cg, 3d, unreal, animate, not human, no head,(low quality, worst quality:1.4), cgi,  text, signature, watermark, extra limbs, cleavage",
  "disableSafetyChecker": true
}

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

Aquaaibase's "Generate Custom Image Inpaint" action empowers developers to create stunning, customized images with ease. By leveraging advanced image processing techniques, you can bring your creative visions to life, whether for marketing, design, or content creation. Start integrating Aquaaibase into your projects today, and unlock a new level of visual storytelling!