Create Stunning Images with Mani Images' Inpainting Action

In today's digital landscape, the ability to generate high-quality images quickly and efficiently is paramount for developers and creatives alike. The "Mani Images" service offers a powerful Cognitive Action specifically designed for image generation through inpainting. This action allows you to create stunning visuals by leveraging advanced image-to-image techniques and customizable parameters, making it easier than ever to produce tailored graphics for a variety of applications.
Imagine the possibilities: whether you're developing a game, designing marketing materials, or enhancing visual content for social media, Mani Images enables you to generate images that meet your specific needs in a fraction of the time it would traditionally take. With customizable options for image size, quality, and style, the service opens up new avenues for creativity and efficiency.
Prerequisites
To get started with Mani Images, you'll need a Cognitive Actions API key and a basic understanding of making API calls. This will allow you to integrate the image generation capabilities into your applications seamlessly.
Generate Image with Inpainting
The "Generate Image with Inpainting" action provides a versatile solution for creating images based on your unique prompts. It utilizes both image-to-image and inpainting modes, allowing for a high degree of customization and control over the final output.
Purpose
This action is designed to solve the challenge of creating visually appealing images that fit specific concepts or themes. By using a combination of input parameters, developers can generate images that reflect their creative vision accurately.
Input Requirements
The action requires a structured input that includes:
- Prompt: A descriptive text guiding the image generation.
- Image: URI of the input image for inpainting or image-to-image generation.
- Mask: URI of the image mask for specific areas to be inpainted.
- Model Choice: Selection between different inference models.
- Dimensions: Width and height, if a custom aspect ratio is specified.
- Quality and Format: Options to determine the output quality and file format.
Example input:
{
"seed": 13,
"model": "dev",
"prompt": "A hyper-detailed close-up of MANI, prominent cheekbones. His expression is calm, under cool evening light. The background features an out-of-focus sunset behind tree branches.",
"loraScale": 1,
"guidanceScale": 3.5,
"promptStrength": 0.8,
"numberOfOutputs": 1,
"imageOutputFormat": "jpg",
"aspectRatioOptions": "5:4",
"imageOutputQuality": 90,
"additionalLoraScale": 1,
"inferenceStepsCount": 28
}
Expected Output
The output will be a generated image based on the provided prompt and parameters, delivered in the specified format. For example, the result could be a high-resolution image of a calm figure against a beautifully blended sunset background.
Example output:
https://assets.cognitiveactions.com/invocations/ddb1ce39-2ae1-4385-bc63-13c516c49caf/244f347a-60a9-49f2-a082-54e76b97b392.jpg
Use Cases for this Action
- Creative Design: Artists and designers can use this action to quickly produce concepts for visual projects, allowing for rapid iterations and adjustments based on client feedback.
- Marketing Materials: Generate customized images for advertisements, social media posts, and promotional content that align with brand aesthetics.
- Game Development: Create character designs, backgrounds, or promotional images that are unique and tailored to the game's narrative.
- Content Creation: Bloggers and content creators can enhance their articles with relevant images generated specifically for their topics, improving engagement and visual appeal.
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 = "91cde4b4-7dfd-4660-a920-40264e91cbe2" # 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 = {
"seed": 13,
"model": "dev",
"prompt": "A hyper-detailed close-up of MANI, prominent cheekbones. His expression is calm, under cool evening light. The background features an out-of-focus sunset behind tree branches.",
"loraScale": 1,
"guidanceScale": 3.5,
"promptStrength": 0.8,
"numberOfOutputs": 1,
"imageOutputFormat": "jpg",
"aspectRatioOptions": "5:4",
"imageOutputQuality": 90,
"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
The "Generate Image with Inpainting" action from Mani Images empowers developers to create stunning, customized images efficiently. With its flexible parameters and advanced features, this action is an invaluable tool for anyone looking to enhance their visual content creation process.
As you explore the capabilities of Mani Images, consider how you can integrate this action into your projects to elevate your creative output. Whether for personal use or professional applications, the possibilities are endless. Start generating your images today!