Create Stunning Images with Moriaas’ Inpainting Action

26 Apr 2025
Create Stunning Images with Moriaas’ Inpainting Action

In today's digital landscape, the demand for high-quality images is ever-growing, whether for marketing, content creation, or personal projects. Moriaas offers a powerful Cognitive Action known as "Generate Image with Inpainting," which allows developers to create and modify images effortlessly using AI. This action harnesses the capabilities of image inpainting to generate captivating visuals based on user-defined text prompts, existing images, and masks.

The flexibility and customization options provided by this action not only streamline the image creation process but also enhance creativity, enabling developers to produce unique content quickly and efficiently. Common use cases include generating promotional graphics, enhancing existing images, creating art for social media, or even producing assets for games and applications. Why spend hours on manual image editing when you can leverage Moriaas to automate and elevate your creative workflow?

Prerequisites

To get started with Moriaas’ Cognitive Actions, you will need an API key. Familiarity with making API calls will also be beneficial as you integrate this powerful functionality into your applications.

Generate Image with Inpainting

The "Generate Image with Inpainting" action is designed to create or modify images based on a combination of a text prompt, an input image, and an optional mask. This action allows for fine-tuning of numerous parameters, ensuring that the output meets specific needs and quality standards.

Purpose

This action solves the problem of generating tailored images quickly, allowing developers to create high-quality visuals with minimal effort. By adjusting parameters such as image size, output format, and quality, users can achieve optimal results for their specific use cases.

Input Requirements

To use this action, you must provide a JSON object that includes the following required fields:

  • prompt: A description of the image you wish to generate (e.g., "A highly realistic woman looking at the camera").
  • model: Choose between "dev" for optimal performance or "schnell" for faster generation.
  • aspectRatio: Defines the aspect ratio of the generated image.
  • outputFormat: Select the desired output image format (e.g., jpg, png).
  • Additional optional fields include mask, seed, image, width, height, guidanceScale, outputQuality, denoisingSteps, and more.

Expected Output

The expected output is a URI link to the generated image based on the input specifications. For example:

  • "https://assets.cognitiveactions.com/invocations/.../generated-image.jpg"

Use Cases for this Action

  • Marketing and Advertising: Create eye-catching promotional materials tailored to specific campaigns.
  • Content Creation: Generate unique images for blogs, social media posts, or digital publications.
  • Art and Design: Explore creative possibilities by modifying existing artworks or generating entirely new pieces.
  • Game Development: Produce assets for characters, backgrounds, or items within a game environment.
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 = "6f9760b7-9f83-4bc0-aed1-d525d5c377bf" # 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": "moriaas  A highly realistic woman looking to the camera",
  "aspectRatio": "16:9",
  "outputFormat": "jpg",
  "guidanceScale": 3,
  "outputQuality": 80,
  "denoisingSteps": 28,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "optimizeForSpeed": false,
  "mainLoraIntensity": 1,
  "approximateMegapixels": "1",
  "additionalLoraIntensity": 1
}

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 Image with Inpainting" action from Moriaas is a game-changer for developers looking to enhance their projects with high-quality, customized images. With its extensive customization options and intuitive input requirements, integrating this action can significantly streamline your creative processes.

As you explore the capabilities of Moriaas, consider how you can apply this technology across various industries and projects. Embrace the future of image creation and elevate your content with Moriaas today!