Create Stunning Art with the se3tethb/sajad_gen Cognitive Actions

The se3tethb/sajad_gen API provides powerful Cognitive Actions for developers looking to integrate advanced image generation capabilities into their applications. With the ability to create detailed and artistic images through inpainting and image-to-image conversion, these actions allow for extensive customization, including aspect ratios, output formats, and prompt strengths. This article will guide you through the integration of the Generate Image with Inpainting action, illustrating how to harness its features for creating visually captivating content.
Prerequisites
To get started with the Cognitive Actions, you will need an API key for the Cognitive Actions platform. This key will allow you to authenticate your requests. Typically, authentication is handled by passing the API key in the headers of your HTTP requests. Make sure to keep your key secure and not expose it in public repositories.
Cognitive Actions Overview
Generate Image with Inpainting
The Generate Image with Inpainting action enables you to create intricate images using both image-to-image and inpainting modes. This action supports customizable dimensions, various aspect ratios, and different output formats, providing you with the flexibility to tailor the image generation process to meet your specific needs.
Input
The input schema for this action requires the following fields:
- prompt (required): A detailed description of the image you want to generate.
- mask (optional): An image mask for inpainting mode.
- seed (optional): A random seed to ensure reproducibility.
- image (optional): A source image for transformations.
- width (optional): Custom width for the generated image, only applicable if the aspect ratio is set to custom.
- height (optional): Custom height for the generated image, only applicable if the aspect ratio is set to custom.
- numberOfOutputs (optional): The number of output images to generate, with a maximum of 4.
- imageAspectRatio (optional): The aspect ratio for the image, defaulting to "1:1."
- imageOutputFormat (optional): The desired format of the output images (e.g., webp, jpg, png).
- imageOutputQuality (optional): The quality of the output image, ranging from 0 to 100.
- inferenceStepsCount (optional): Number of denoising steps for image generation, affecting detail.
- additional parameters: Various options to control the generation process such as LoRA weights, fast mode, and guidance scales.
Here's an example input for generating an image:
{
"prompt": "In the foreground, a religious figure wearing a black turban and a black cloak with a long white beard and a deep, calm gaze appears.\n\nIn the background, an Islamic architectural arch built of light brown stone appears, through which a golden dome topped with a banner appears in a night scene where the full moon appears majestically amidst the clouds.\n\nThe lighting in the image is dramatic as the moonlight shines behind the dome, creating a spiritual aura around the scene.\n\nThe colors in the image are harmonious and range from dark blue for the background to gold for the dome and brown for the stone arch, creating a spiritual and deep atmosphere.\n\nThe design as a whole combines realism in the character's features and symbolism in the architectural and natural elements in a professional artistic style.",
"mainLoraScale": 1,
"inferenceModel": "dev",
"numberOfOutputs": 4,
"promptInfluence": 0.8,
"imageAspectRatio": "16:9",
"imageOutputFormat": "webp",
"imageOutputQuality": 90,
"additionalLoraScale": 1,
"inferenceStepsCount": 50,
"diffusionGuidanceScale": 3.5
}
Output
Upon successful execution, the action returns an array of URLs pointing to the generated images. Here’s an example of the output you might receive:
[
"https://assets.cognitiveactions.com/invocations/586d4d3a-62f1-4621-9315-eb330c233e35/c4e60edc-bbe7-4bf6-acb1-fcc667f3faaf.webp",
"https://assets.cognitiveactions.com/invocations/586d4d3a-62f1-4621-9315-eb330c233e35/b750cbe9-84ea-4813-9618-71c0ab567870.webp",
"https://assets.cognitiveactions.com/invocations/586d4d3a-62f1-4621-9315-eb330c233e35/ac353037-c81b-4eae-abe8-7c8a1501c92f.webp",
"https://assets.cognitiveactions.com/invocations/586d4d3a-62f1-4621-9315-eb330c233e35/f8e0378f-4489-4857-b475-64edd4dbd07e.webp"
]
Conceptual Usage Example (Python)
Below is a conceptual Python code snippet to illustrate how you can invoke the Generate Image with Inpainting action using a hypothetical 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 = "78d26745-af2d-4358-8fb0-2d1013521910" # Action ID for Generate Image with Inpainting
# Construct the input payload based on the action's requirements
payload = {
"prompt": "In the foreground, a religious figure wearing a black turban and a black cloak with a long white beard and a deep, calm gaze appears.\n\nIn the background, an Islamic architectural arch built of light brown stone appears, through which a golden dome topped with a banner appears in a night scene where the full moon appears majestically amidst the clouds.\n\nThe lighting in the image is dramatic as the moonlight shines behind the dome, creating a spiritual aura around the scene.\n\nThe colors in the image are harmonious and range from dark blue for the background to gold for the dome and brown for the stone arch, creating a spiritual and deep atmosphere.\n\nThe design as a whole combines realism in the character's features and symbolism in the architectural and natural elements in a professional artistic style.",
"mainLoraScale": 1,
"inferenceModel": "dev",
"numberOfOutputs": 4,
"promptInfluence": 0.8,
"imageAspectRatio": "16:9",
"imageOutputFormat": "webp",
"imageOutputQuality": 90,
"additionalLoraScale": 1,
"inferenceStepsCount": 50,
"diffusionGuidanceScale": 3.5
}
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 placeholder for the API key and endpoint with your actual credentials. The payload variable constructs the necessary input for the action, and the response will contain URLs to the generated images.
Conclusion
The se3tethb/sajad_gen Cognitive Action for generating images with inpainting opens up a world of creative possibilities for developers. With customizable parameters, the ability to create stunning images tailored to user specifications, and an intuitive API structure, you can easily integrate advanced image generation into your applications. Start experimenting with the Generate Image with Inpainting action and unlock your creative potential!