Create Stunning Images with Mandolora's Inpainting and Control Features

In the world of digital content creation, the ability to generate high-quality images quickly and efficiently can significantly enhance workflows. Mandolora offers a powerful set of Cognitive Actions that facilitate image generation through advanced techniques like inpainting and LoRA (Low-Rank Adaptation) control. This service empowers developers to create visually stunning images tailored to specific needs, all while maintaining flexibility in parameters such as dimensions, aspect ratios, and output quality.
Common use cases for Mandolora's image generation capabilities include enhancing graphic design projects, producing unique artwork, generating illustrations for marketing materials, and even creating visual content for social media. By utilizing these Cognitive Actions, developers can streamline their creative processes, reduce manual effort, and achieve professional-grade results in less time.
Prerequisites
Before diving into the implementation of Mandolora’s Cognitive Actions, ensure you have your API key ready and a basic understanding of making API calls.
Generate Image with Inpainting and LoRA Control
The "Generate Image with Inpainting and LoRA Control" action is designed to create high-quality images by leveraging advanced image inpainting techniques and customizable LoRA control parameters. This action is particularly useful for scenarios where you need to fill in missing parts of images or create variations based on specific prompts.
Input Requirements
To utilize this action, you need to provide several inputs:
- Prompt: A text description guiding the image generation (e.g., "The image is of a mandolin in a field of grass...").
- Mask: A URI pointing to an image mask for inpainting (optional).
- Image: A URI pointing to an input image for transformation (optional).
- Aspect Ratio, Width, Height: Parameters for the output image dimensions.
- Go Fast: A boolean to toggle between speed and quality.
- Output Format: Choose from webp, jpg, or png.
- Guidance Scale, Output Quality, Inference Model: Various parameters to fine-tune the output.
Example input:
{
"prompt": "The image is of a mandolin in a field of grass.",
"loraScale": 1,
"numOutputs": 1,
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceScale": 3,
"outputQuality": 90,
"inferenceModel": "dev",
"numInferenceSteps": 28
}
Expected Output
The output will be a generated image URL (e.g., "https://assets.cognitiveactions.com/invocations/..."), allowing easy access to the created images.
Use Cases for this Specific Action
- Creative Projects: Artists and designers can generate unique illustrations or artwork based on textual descriptions.
- Marketing Materials: Businesses can create tailored visuals for campaigns or advertisements to capture audience attention.
- Social Media Content: Content creators can produce engaging images that align with their brand's theme or message.
- Game Development: Developers can generate concept art or textures for characters and environments.
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 = "6a874a43-7635-49a3-9558-a32fbb11c660" # Action ID for: Generate Image with Inpainting and LoRA Control
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"prompt": "The image is of a mandolin in a field of grass. The mandolin is made of figured woods with a glossy natural finish.",
"loraScale": 1,
"numOutputs": 1,
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceScale": 3,
"outputQuality": 90,
"extraLoraScale": 1,
"inferenceModel": "dev",
"promptStrength": 0.8,
"numInferenceSteps": 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
Mandolora's image generation capabilities through inpainting and LoRA control offer a transformative solution for developers looking to create high-quality visuals efficiently. With customizable parameters and the ability to generate images based on descriptive prompts, the possibilities are vast. Whether for professional design projects, marketing efforts, or personal creative endeavors, integrating Mandolora into your workflow can significantly enhance your output. Start exploring these Cognitive Actions today to elevate your image generation capabilities!