Mastering Image Generation with the NeureaLenin Cognitive Actions

In the world of AI-driven creativity, the NeureaLenin Cognitive Actions provide developers with powerful tools to generate stunning images using a fine-tuned Stable Diffusion model. This integration allows you to leverage the artistic potential of the NeureaLenin model, which has been specifically trained with colorized photos of V. I. Lenin. By utilizing these pre-built actions, developers can effortlessly incorporate advanced image generation capabilities into their applications, enhancing user experiences and creative outputs.
Prerequisites
Before you can start using the NeureaLenin Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform.
- Basic understanding of how to make HTTP requests and handle JSON payloads.
Authentication is generally achieved by passing your API key in the request headers, allowing you to securely interact with the Cognitive Actions service.
Cognitive Actions Overview
Fine-Tune NeureaLenin Model
The Fine-Tune NeureaLenin Model action allows you to generate images by utilizing a fine-tuned Stable Diffusion XL LORA model. You can enhance the thematic generation of images by including the 'LEN' token in your prompts.
- Category: Image Generation
Input
The input for this action is a structured JSON object. Here’s a breakdown of the fields:
- prompt (string): The text prompt that guides the image generation process. (e.g., "UHD award-winning photo of LEN person in a cyberpunk post-Soviet wasteland")
- width (integer): Width of the output image in pixels. Default is 1024. (e.g., 1024)
- height (integer): Height of the output image in pixels. Default is 1024. (e.g., 1120)
- outputCount (integer): Number of images to generate (between 1 and 4). Default is 1. (e.g., 1)
- guidanceScale (number): Scale for classifier-free guidance (1 to 50). Default is 7.5. (e.g., 12.3)
- applyWatermark (boolean): Whether to apply a watermark to generated images. Default is true. (e.g., false)
- negativePrompt (string): Specifies what to avoid in the generated image. (e.g., "bad quality, cgi...")
- promptStrength (number): Strength of the prompt when using img2img or inpaint mode (0 to 1). Default is 0.8. (e.g., 0.8)
- refine (string): Specifies the refinement style. Default is "no_refiner". (e.g., "no_refiner")
- loraLevel (number): LoRA additive scale for trained models (0 to 1). Default is 0.6. (e.g., 0.7)
- scheduler (string): Type of scheduler to use for denoising. Default is "K_EULER". (e.g., "K_EULER")
- inferenceStepCount (integer): Number of denoising steps to perform (1 to 500). Default is 50. (e.g., 50)
- refinementSteps (integer): Number of steps for refinement when using the base image refiner. (e.g., 15)
- highNoiseFraction (number): Fraction of noise for expert ensemble refiner (0 to 1). Default is 0.8. (e.g., 0.8)
- seed (integer, optional): Random seed value. Leave blank for a randomized seed. (e.g., 12345)
- mask (string, optional): URL of the input mask for inpaint mode. (e.g., "http://example.com/mask.png")
- image (string, optional): URL of the input image for img2img or inpaint mode. (e.g., "http://example.com/image.png")
Example Input:
{
"width": 1024,
"height": 1120,
"prompt": "UHD award-winning photo of LEN person in a cyberpunk post-Soviet wasteland",
"refine": "no_refiner",
"loraLevel": 0.7,
"scheduler": "K_EULER",
"outputCount": 1,
"guidanceScale": 12.3,
"applyWatermark": false,
"negativePrompt": "bad quality, cgi, cartoon, video game, unrealistic, digital, 3d graphics, drawing, illustration, synthetic, computer graphics, low quality, unnatural anatomy, bad proportions, aliasing, glossy simplistic textures, malformed limbs, ",
"promptStrength": 0.8,
"refinementSteps": 15,
"highNoiseFraction": 0.8,
"inferenceStepCount": 50
}
Output
Upon executing the action, you will receive a JSON response containing the URL(s) of the generated image(s). Here's an example of what the output might look like:
[
"https://assets.cognitiveactions.com/invocations/f39ddca4-01fd-4bc4-a73a-e63c7a7191b8/77c0f126-dfeb-403d-b9a5-5b9de0ed9f31.png"
]
Conceptual Usage Example (Python)
Here’s how you might structure a Python script to invoke this action:
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 = "70039a14-e457-4f3d-8af4-0bd2c329fa66" # Action ID for Fine-Tune NeureaLenin Model
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1120,
"prompt": "UHD award-winning photo of LEN person in a cyberpunk post-Soviet wasteland",
"refine": "no_refiner",
"loraLevel": 0.7,
"scheduler": "K_EULER",
"outputCount": 1,
"guidanceScale": 12.3,
"applyWatermark": False,
"negativePrompt": "bad quality, cgi, cartoon, video game, unrealistic, digital, 3d graphics, drawing, illustration, synthetic, computer graphics, low quality, unnatural anatomy, bad proportions, aliasing, glossy simplistic textures, malformed limbs, ",
"promptStrength": 0.8,
"refinementSteps": 15,
"highNoiseFraction": 0.8,
"inferenceStepCount": 50
}
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 example, the script constructs a JSON payload using the required fields for the Fine-Tune NeureaLenin Model action. The API key is included in the headers for authentication, and the response is printed out in a readable format.
Conclusion
The NeureaLenin Cognitive Actions provide a robust framework for developers looking to enhance their applications with advanced image generation capabilities. By leveraging the Fine-Tune NeureaLenin Model action, you can create unique and thematic images that stand out. Explore the possibilities of integrating these actions into your projects, and unleash your creativity with AI-driven image generation!