Generate Stunning Custom Images with the zeg06/arthur Cognitive Actions

In the world of image generation, the zeg06/arthur API offers developers a powerful toolset to create high-quality and customized images. With features like image inpainting and transformation capabilities, these Cognitive Actions enable rapid image creation tailored to specific prompts. By utilizing pre-built actions, developers can save time and effort while harnessing advanced image processing technology.
Prerequisites
Before diving into the integration of Cognitive Actions, ensure you have the following:
- An API key for the zeg06/arthur platform to authenticate your requests.
- Basic understanding of JSON structure as the input and output will be in this format.
Conceptually, authentication typically involves passing your API key in the request headers, allowing secure access to the Cognitive Actions.
Cognitive Actions Overview
Generate Enhanced Images
Description: This action produces high-quality, customized images using advanced techniques such as image inpainting and transformation. The action supports various image aspects, resolutions, and styles, with options for fast generation.
Category: Image Processing
Input
The input schema for this action requires a prompt and may include several optional fields. Here’s a breakdown of the required and optional input fields based on the schema:
- Required:
prompt: (string) A detailed description of the desired image content.
- Optional:
mask: (string) URI of the image mask for inpainting.seed: (integer) A random seed for reproducible results.image: (string) URI of the input image for inpainting mode.model: (string) Specifies the model for inference (devorschnell).width: (integer) Width of the generated image (if aspect ratio is 'custom').height: (integer) Height of the generated image (if aspect ratio is 'custom').aspectRatio: (string) Specifies the aspect ratio for the generated image.outputCount: (integer) Number of images to generate (1 to 4).outputFormat: (string) File format for the output images (webp,jpg, orpng).guidanceScale: (number) Adjusts the guidance strength in the generation process.outputQuality: (integer) Quality level when saving output images.enableFastMode: (boolean) Enables faster predictions using a speed-optimized model.promptStrength: (number) Determines prompt strength for image transformations.imageMegapixels: (string) Approximate number of megapixels in the generated image.bypassSafetyCheck: (boolean) Option to disable the safety checker.mainLoraIntensity: (number) Adjusts the intensity of the main LoRA.inferenceStepCount: (integer) Number of denoising steps.additionalLoraWeights: (string) URI for loading additional LoRA weights.additionalLoraIntensity: (number) Sets intensity for the additional LoRA.
Example Input:
{
"model": "dev",
"prompt": "Ultrarealistic photo of Arthur wearing summer attire including stylish eyeglasses and a vibrant Hawaiian shirt, confidently steers a small luxury yacht through calm, crystal-clear waters. The yacht’s sleek white design glistens under the bright sunlight. Behind Arthur, a group of beautiful women in colorful bikinis lounge and smile, enjoying the warm breeze and vibrant atmosphere. The setting radiates tropical luxury, with a background of turquoise ocean waves and a distant view of lush green islands under a clear blue sky",
"aspectRatio": "9:16",
"outputCount": 1,
"outputFormat": "webp",
"guidanceScale": 3,
"outputQuality": 80,
"enableFastMode": false,
"promptStrength": 0.8,
"imageMegapixels": "1",
"mainLoraIntensity": 1,
"inferenceStepCount": 50,
"additionalLoraIntensity": 1
}
Output
The action typically returns a list of image URLs in the specified output format. Here’s an example of the output you can expect:
Example Output:
[
"https://assets.cognitiveactions.com/invocations/d16a4a63-1fb3-4fd7-840a-90d8427c90ad/49654f49-02b3-43c5-83b9-2fb7fcfbe4ef.webp"
]
Conceptual Usage Example (Python)
Here’s how you might call the Generate Enhanced Images action using Python:
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 = "7276597d-b37e-4cc2-a962-a62b62e5d304" # Action ID for Generate Enhanced Images
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"prompt": "Ultrarealistic photo of Arthur wearing summer attire including stylish eyeglasses and a vibrant Hawaiian shirt, confidently steers a small luxury yacht through calm, crystal-clear waters...",
"aspectRatio": "9:16",
"outputCount": 1,
"outputFormat": "webp",
"guidanceScale": 3,
"outputQuality": 80,
"enableFastMode": False,
"promptStrength": 0.8,
"imageMegapixels": "1",
"mainLoraIntensity": 1,
"inferenceStepCount": 50,
"additionalLoraIntensity": 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 Python snippet, replace the placeholder values with your actual API key and modify the payload as needed. The action ID and the structured input payload are highlighted to show their respective places in the request.
Conclusion
The zeg06/arthur Cognitive Actions provide a robust framework for generating stunning, customized images quickly and efficiently. By leveraging the capabilities of the Generate Enhanced Images action, developers can enhance their applications with unique visual content tailored to their needs. Explore further possibilities by integrating this action into your projects and experiment with various prompts and parameters to achieve the best results!