Generate Stunning Custom Images with karlvann/earth38 Cognitive Actions

In the world of digital creativity, the ability to generate customized images can open up a plethora of possibilities for developers and artists alike. With the karlvann/earth38 Cognitive Actions, you can create high-quality images tailored to your specifications. This API provides robust features for image generation, including fast processing, image inpainting, and adjustable settings for image quality and dimensions. Whether you're building a creative application, enhancing user-generated content, or developing a game, these actions can significantly streamline your workflow.
Prerequisites
Before you start integrating these Cognitive Actions into your application, ensure you have the following:
- An API key for the Cognitive Actions platform to enable authentication.
- Basic knowledge of making HTTP requests.
- Familiarity with JSON data structures.
When making requests, you'll typically pass your API key in the headers. This allows you to authenticate your requests securely.
Cognitive Actions Overview
Generate Custom Images
The Generate Custom Images action allows you to create high-quality, customized images using advanced models. You can utilize features like image inpainting and various adjustable parameters to achieve your desired output.
Input
To invoke this action, you'll need to provide a JSON payload that includes the following required fields:
prompt: A detailed description of the image you wish to generate.
Optional fields include:
mask: An image mask for inpainting mode.seed: A random seed for reproducibility.image: An input image for image-to-image or inpainting mode.width: Width of the generated image in pixels (only if aspect ratio is custom).height: Height of the generated image in pixels (only if aspect ratio is custom).loraScale: Intensity for applying Low-Rank Adaptation (LoRA).numOutputs: Number of images to generate (1 to 4).aspectRatio: Aspect ratio of the generated image.outputFormat: Format of the output images (e.g.,webp,jpg,png).- Additional parameters like
guidanceScale,outputQuality, and more can also be specified.
Here’s an example of the JSON payload you might send:
{
"seed": 60238,
"prompt": "A photo of a model with long blonde hair and a pink onesie sitting on a soft peach floor. The onesie has white around the cuffs. The room is nature themed and evokes a sense of spaciousness. The model's skin tone should contrast warmly with the pajamas, suggesting a tanned complexion. The model has a relaxed pose. Light the scene with warm, diffused lighting, intimate atmosphere. The overall color palette should be dominated by warm tones - peaches, creams, and soft golds. Ensure the image has a slightly dreamy quality, with soft focus and gentle shadows. The composition should evoke a sense of comfort, elegance, and relaxation.",
"loraScale": 1,
"numOutputs": 4,
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceScale": 3.5,
"outputQuality": 90,
"inferenceModel": "dev",
"promptStrength": 0.8,
"numInferenceSteps": 28,
"additionalLoraScale": 1
}
Output
Upon successful execution, the action returns an array of URLs pointing to the generated images. For example:
[
"https://assets.cognitiveactions.com/invocations/e4d21269-70d5-478e-b964-299dccec519f/f1983498-5777-48e9-8dd9-c417b8d3a968.webp",
"https://assets.cognitiveactions.com/invocations/e4d21269-70d5-478e-b964-299dccec519f/41c36260-d811-403b-a5a3-f7f99b0c79b2.webp",
"https://assets.cognitiveactions.com/invocations/e4d21269-70d5-478e-b964-299dccec519f/74b2364c-8fe5-4a58-baf4-f09d24e6db92.webp",
"https://assets.cognitiveactions.com/invocations/e4d21269-70d5-478e-b964-299dccec519f/d3bbecb3-33e8-4e3d-871e-210b3bf659c1.webp"
]
Conceptual Usage Example (Python)
To call this action using Python, you can use the following code snippet:
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 = "148c90a4-1cfa-47e5-b6eb-8d25cc2b8e0c" # Action ID for Generate Custom Images
# Construct the input payload based on the action's requirements
payload = {
"seed": 60238,
"prompt": "A photo of a model with long blonde hair and a pink onesie sitting on a soft peach floor. The onesie has white around the cuffs. The room is nature themed and evokes a sense of spaciousness. The model's skin tone should contrast warmly with the pajamas, suggesting a tanned complexion. The model has a relaxed pose. Light the scene with warm, diffused lighting, intimate atmosphere. The overall color palette should be dominated by warm tones - peaches, creams, and soft golds. Ensure the image has a slightly dreamy quality, with soft focus and gentle shadows. The composition should evoke a sense of comfort, elegance, and relaxation.",
"loraScale": 1,
"numOutputs": 4,
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceScale": 3.5,
"outputQuality": 90,
"inferenceModel": "dev",
"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 snippet, replace the COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID and input payload are structured based on the requirements of the Generate Custom Images action. The endpoint URL and request structure are illustrative and should be adapted as necessary for your implementation.
Conclusion
The karlvann/earth38 Cognitive Actions provide a powerful tool for developers looking to create stunning, customized images with ease. By leveraging the capabilities of the Generate Custom Images action, you can produce high-quality visuals that enhance your applications and engage your users. Start integrating these actions today, and unlock the potential for creativity in your projects!