Enhance Your Images with Mrdm Ostris Inpainting Actions

In the realm of digital content creation, having the ability to manipulate images with precision and creativity is paramount. The Mrdm Ostris service provides developers with powerful Cognitive Actions that streamline image enhancement processes, particularly through the action of generating image inpainting. This action allows for the seamless restoration or modification of images by filling in gaps or altering specific areas based on user-defined prompts. The benefits are clear: enhanced speed, flexibility, and the ability to produce high-quality visuals tailored to specific needs.
Common use cases for image inpainting include restoring old photographs, creating unique artwork, or modifying images for marketing materials. For instance, a developer may want to replace an undesirable background in a product image or creatively alter an image to fit a specific theme for a social media campaign. With Mrdm Ostris, such tasks become straightforward and efficient.
Before diving into the capabilities of Mrdm Ostris, ensure you have your Cognitive Actions API key and a basic understanding of API calls.
Generate Image Inpainting
The "Generate Image Inpainting" action is designed to perform high-quality image restoration or modification based on specified parameters. It solves the problem of needing to fill in missing parts of an image or creatively alter existing elements, making it an essential tool for graphic designers and content creators alike.
Input Requirements
To use this action, you will need to provide a structured input that includes:
- prompt: A descriptive text guiding the inpainting process.
- mask: (Optional) A URI for an image mask.
- image: (Optional) A URI for an input image.
- width and height: Specify dimensions when using a custom aspect ratio.
- numOutputs: Number of images to generate.
- guidanceScale: Scale factor for the diffusion guidance.
- outputQuality: Quality level for the output image.
- inferenceModel: Choice of model for inference, either 'dev' or 'schnell'.
Expected Output
The action will return one or more generated images based on the provided parameters, allowing for further use in various applications. An example output might look like:
https://assets.cognitiveactions.com/invocations/b0531de0-853d-4e13-b5d9-26271cd035db/30b94840-510f-4ba4-9ded-8791e6fc96cb.webp
Use Cases for this Specific Action
This action is particularly useful in scenarios such as:
- Photo Restoration: Reviving old or damaged photographs by intelligently filling in missing areas.
- Creative Design: Altering images to fit artistic projects by modifying backgrounds or adding new elements based on creative prompts.
- Marketing Materials: Tailoring product images for advertisements by removing unwanted elements or enhancing visual appeal.
With the right configuration, developers can leverage this action to produce stunning visuals that meet specific 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 = "31c40673-0953-4808-91c1-9e145709bab1" # Action ID for: Generate Image Inpainting
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"prompt": "mrdm in ornate jewel-toned wizard robes, dramatic front facing portrait, volumetric lighting, shallow depth of field, Canon EOS R5, f/1.8 aperture, golden hour illumination, sharp focus on eyes, 4K resolution.",
"loraScale": 1,
"numOutputs": 1,
"guidanceScale": 3.5,
"outputQuality": 90,
"inferenceModel": "dev",
"imageAspectRatio": "1:1",
"imageOutputFormat": "webp",
"numInferenceSteps": 28,
"additionalLoraScale": 1,
"img2ImgPromptStrength": 0.8
}
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 Mrdm Ostris service provides robust tools for enhancing images through its image inpainting capabilities. By enabling developers to create tailored, high-quality images quickly, it opens up a world of possibilities for creative and commercial applications. As you explore these Cognitive Actions, consider how they can streamline your workflows and elevate your image manipulation tasks. Start integrating Mrdm Ostris today and unlock the full potential of your digital content.