Create Stunning Custom Images with swk23/youngdooku Cognitive Actions

In the realm of image generation, the swk23/youngdooku specification offers powerful Cognitive Actions that allow developers to create customized images through advanced inpainting and image-to-image techniques. By leveraging pre-built actions, you can easily integrate sophisticated functionality into your applications, enhancing user experiences with tailored visual content.
Prerequisites
To get started with the Cognitive Actions of swk23/youngdooku, ensure you have:
- An API key for the Cognitive Actions platform.
- A basic understanding of JSON structure for API requests.
Authentication typically involves passing your API key in the request headers, allowing you to securely access the Cognitive Actions services.
Cognitive Actions Overview
Generate Custom Images with Inpainting
Description:
This action allows you to create customized images by either providing an image input or generating new images based on specific prompts. It utilizes advanced inpainting and image-to-image techniques, ensuring flexibility and creativity in your image generation tasks.
Category: image-generation
Input
The following JSON schema outlines the required and optional fields for this action:
{
"prompt": "string",
"mask": "string (optional)",
"seed": "integer (optional)",
"image": "string (optional)",
"width": "integer (optional)",
"height": "integer (optional)",
"outputCount": "integer (default: 1, optional)",
"modelWeights": "string (optional)",
"guidanceScale": "number (default: 3, optional)",
"outputQuality": "integer (default: 80, optional)",
"additionalLora": "string (optional)",
"denoisingSteps": "integer (default: 28, optional)",
"inferenceModel": "string (default: 'dev', optional)",
"promptStrength": "number (default: 0.8, optional)",
"fastModeEnabled": "boolean (default: false, optional)",
"approxMegapixels": "string (default: '1', optional)",
"imageAspectRatio": "string (default: '1:1', optional)",
"imageOutputFormat": "string (default: 'webp', optional)",
"mainLoraIntensity": "number (default: 1, optional)",
"additionalLoraIntensity": "number (default: 1, optional)",
"disableImageSafetyChecker": "boolean (default: false, optional)"
}
Example Input:
{
"prompt": "close up of A character standing tall holding a glowing blue lightsaber in a waist-up shot. The lightsaber is positioned upright to the side, ensuring it does not block the character's face. The background features an outdoor scene with a clear blue sky and soft greenery, adding serenity to the powerful composition.",
"outputCount": 1,
"guidanceScale": 3,
"outputQuality": 80,
"denoisingSteps": 28,
"inferenceModel": "dev",
"promptStrength": 0.8,
"fastModeEnabled": false,
"approxMegapixels": "1",
"imageAspectRatio": "21:9",
"imageOutputFormat": "jpg",
"mainLoraIntensity": 1,
"additionalLoraIntensity": 1
}
Output
The action typically returns a URL to the generated image. Here’s an example of what the output might look like:
[
"https://assets.cognitiveactions.com/invocations/37a6fa81-9eb8-490c-81c7-a3437b555f78/95774c18-e434-45a7-b0be-526df4aef55f.jpg"
]
Conceptual Usage Example (Python)
Below is a conceptual example of how you might call the Generate Custom Images with Inpainting action using Python. This snippet illustrates how to structure the input JSON payload correctly:
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 = "ec307efc-c979-403d-a4cf-395cf371e699" # Action ID for Generate Custom Images with Inpainting
# Construct the input payload based on the action's requirements
payload = {
"prompt": "close up of A character standing tall holding a glowing blue lightsaber in a waist-up shot. The lightsaber is positioned upright to the side, ensuring it does not block the character's face. The background features an outdoor scene with a clear blue sky and soft greenery, adding serenity to the powerful composition.",
"outputCount": 1,
"guidanceScale": 3,
"outputQuality": 80,
"denoisingSteps": 28,
"inferenceModel": "dev",
"promptStrength": 0.8,
"fastModeEnabled": False,
"approxMegapixels": "1",
"imageAspectRatio": "21:9",
"imageOutputFormat": "jpg",
"mainLoraIntensity": 1,
"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 code, you will find the action ID and input payload clearly defined. The endpoint URL and request structure are illustrative and should be replaced with actual values pertinent to your setup.
Conclusion
The swk23/youngdooku Cognitive Actions provide an impressive means of generating custom images, enabling developers to harness the power of advanced image processing techniques effortlessly. By integrating these actions, you can create unique visual content tailored to your application's needs. Explore the possibilities and enhance your projects with stunning, personalized imagery!