Create Stunning Images with Inpainting Using majusculeqc/distordius Cognitive Actions

The majusculeqc/distordius specification provides developers with powerful Cognitive Actions aimed at generating high-quality images through advanced inpainting techniques. These pre-built actions enable seamless integration into applications, allowing for customizable image creation that meets specific project needs. By leveraging these Cognitive Actions, developers can automate image generation processes, enhance creative projects, and produce visually striking content efficiently.
Prerequisites
Before diving into the integration of Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform to authenticate your requests.
- Basic knowledge of JSON and how to make HTTP requests in your programming environment.
- Familiarity with Python (optional but helpful for the conceptual code examples).
You will typically pass the API key in the request headers to authenticate your API calls.
Cognitive Actions Overview
Generate Image with Inpainting
The Generate Image with Inpainting action allows developers to create stunning images by leveraging inpainting techniques. This action supports various customizable settings for the image mask, resolution, and output format, along with options for optimizing speed and image quality.
- Category: Image Generation
Input
The input for this action requires a JSON object with the following schema:
{
"prompt": "string (required)",
"mask": "string (optional, format: uri)",
"seed": "integer (optional)",
"image": "string (optional, format: uri)",
"width": "integer (optional, between 256 and 1440)",
"goFast": "boolean (optional, default: false)",
"height": "integer (optional, between 256 and 1440)",
"loraScale": "number (optional, default: 1)",
"modelType": "string (optional, default: 'dev')",
"numOutputs": "integer (optional, default: 1, between 1 and 4)",
"aspectRatio": "string (optional, default: '1:1')",
"outputFormat": "string (optional, default: 'webp')",
"guidanceScale": "number (optional, default: 3)",
"outputQuality": "integer (optional, default: 80, between 0 and 100)",
"megapixelCount": "string (optional, default: '1')",
"promptStrength": "number (optional, default: 0.8)",
"numInferenceSteps": "integer (optional, default: 28)",
"additionalLoraScale": "number (optional, default: 1)",
"disableSafetyChecker": "boolean (optional, default: false)"
}
Example Input:
{
"goFast": false,
"prompt": "Photorealistic image, 8K resolution, ultra-detailed, depicting a film set, indoors, with a slightly smoky atmosphere. In the midground, MAJUSCULE, the film director stands facing the camera directly. The scene is illuminated with a strong, directional, cool blue light source coming from the top right of the frame.",
"loraScale": 1,
"modelType": "dev",
"numOutputs": 1,
"aspectRatio": "16:9",
"outputFormat": "webp",
"guidanceScale": 3,
"outputQuality": 80,
"megapixelCount": "1",
"promptStrength": 0.8,
"numInferenceSteps": 28,
"additionalLoraScale": 1
}
Output
The output of this action is typically a URL pointing to the generated image. The response structure may vary based on the request, but it generally returns a JSON object containing the output URL.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/5dde54b4-0227-42b4-a009-ef1f941d8687/d333decb-1a1b-4c5f-b3ed-577e9e1a5556.webp"
]
Conceptual Usage Example (Python)
Below is a conceptual example of how to call the Generate Image with Inpainting action using Python. This code demonstrates how to structure the input JSON payload and make a request to the Cognitive Actions endpoint.
import requests
import json
# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint
action_id = "ab884d67-1d95-47a8-b9e5-d370e3a9f475" # Action ID for Generate Image with Inpainting
# Construct the input payload based on the action's requirements
payload = {
"goFast": False,
"prompt": "Photorealistic image, 8K resolution, ultra-detailed, depicting a film set, indoors, with a slightly smoky atmosphere...",
"loraScale": 1,
"modelType": "dev",
"numOutputs": 1,
"aspectRatio": "16:9",
"outputFormat": "webp",
"guidanceScale": 3,
"outputQuality": 80,
"megapixelCount": "1",
"promptStrength": 0.8,
"numInferenceSteps": 28,
"additionalLoraScale": 1
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json"
}
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json={"action_id": action_id, "inputs": payload} # Hypothetical structure
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully:")
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: {e.response.text}")
In this code snippet, the developer needs to replace the COGNITIVE_ACTIONS_API_KEY with their actual API key. The action ID is set to match the Generate Image with Inpainting action, and the input payload is structured according to the action's requirements. The endpoint URL and request structure are illustrative and may vary based on actual integration.
Conclusion
The majusculeqc/distordius Cognitive Actions provide a robust solution for generating high-quality images using inpainting techniques. By utilizing the Generate Image with Inpainting action, developers can effortlessly create stunning visuals tailored to their specific needs. As you explore these capabilities, consider experimenting with different settings and prompts to unlock the full potential of image generation in your applications. Happy coding!