Create Stunning Images with Maor's Inpainting Feature

26 Apr 2025
Create Stunning Images with Maor's Inpainting Feature

Maor is an innovative service designed to empower developers with advanced image generation capabilities. One of its standout features is the ability to generate images with inpainting, enabling users to create detailed, customized visuals based on specified parameters. This functionality allows for the manipulation of existing images or the generation of entirely new ones, making it an invaluable tool for creative projects, marketing materials, and more.

By leveraging Maor's Cognitive Actions, developers can easily automate the creation of unique images, saving time while enhancing productivity. Whether you need to fill in missing parts of an image, create variations, or generate entirely new concepts, Maor's inpainting capabilities offer the flexibility and speed that modern applications demand.

Prerequisites

To get started with Maor, ensure you have a valid Cognitive Actions API key and a basic understanding of making API calls.

Generate Image with Inpainting

This action allows users to generate images with specified parameters, including inpainting capabilities using image masks. The "dev" model excels with detailed generation in approximately 28 steps, while the "schnell" model achieves faster results with minimal steps. Users can customize various aspects such as image dimensions, format, quality, and utilize LoRA settings for enhanced output.

Input Requirements

The input for this action requires a structured object, including:

  • prompt: A descriptive input for generating the image (required).
  • mask: URI for the image mask to be used in inpainting mode (optional).
  • seed: Random seed for consistent outputs (optional).
  • width and height: Set dimensions for the generated image (optional, must be multiples of 16).
  • aspectRatio: Select from standard ratios or use custom dimensions (optional).
  • modelWeights: Load model weights from various sources (optional).
  • guidanceScale: Controls how much the prompt influences the generation (optional).
  • inferenceModel: Choose between "dev" or "schnell" for inference (optional).
  • outputQuantity: Specify how many images to generate (optional).
  • outputImageFormat: Choose the format (webp, jpg, png) for the output images (optional).
  • Additional parameters for fine-tuning the output such as promptStrength, imageMegapixels, and LoRA settings.

Expected Output

The output will be a URI link to the generated image, which can be utilized in applications or shared as needed.

Use Cases for this specific action

  • Content Creation: Generate unique visuals for blog posts, social media, or marketing materials.
  • Artistic Projects: Artists can create variations or entirely new pieces based on a given prompt.
  • E-commerce: Create custom product images that align with branding or seasonal themes.
  • Game Development: Generate concept art or assets for characters and environments based on narrative requirements.
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 = "a5ab3ae5-fb3f-4207-93b9-f33af2a7c5e1" # 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 = {
  "width": 737,
  "prompt": "Maor is a guitar player with an Orange les-Paul guitar on an black crane in a construction site. He has an orange construction vest, black T-shirt, orange trucks, grey walls, sand",
  "aspectRatio": "1:1",
  "guidanceScale": 3,
  "mainLoraScale": 1,
  "enableFastMode": false,
  "inferenceModel": "dev",
  "outputQuantity": 1,
  "promptStrength": 0.8,
  "imageMegapixels": "1",
  "outputImageFormat": "webp",
  "outputImageQuality": 80,
  "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

Maor's image generation with inpainting is a powerful tool for developers looking to enhance their applications with unique and customizable visuals. The ability to specify parameters such as prompts, dimensions, and formats allows for a high degree of creativity and flexibility. As you explore these capabilities, consider how they can streamline your workflow and elevate your projects. Start integrating Maor today to harness the full potential of automated image generation!