Create Stunning Images with the fofr/flux-neo-1x Cognitive Actions

In the world of artificial intelligence, the ability to generate high-quality images from textual prompts has become increasingly popular. The fofr/flux-neo-1x specification provides a powerful Cognitive Action that allows developers to create images using the Flux Lora model, specifically fine-tuned for the NEO-1X robot. By leveraging this action, you can customize various parameters to create images that suit your application's needs. Let's dive into how to effectively use this action to enhance your projects.
Prerequisites
Before you start using the Cognitive Actions in the fofr/flux-neo-1x spec, ensure you have the following:
- An API key for the Cognitive Actions platform, which you will use to authenticate your requests.
- Familiarity with making HTTP requests and handling JSON data.
- Basic knowledge of Python for the conceptual examples provided.
Authentication typically involves passing your API key in the request headers to authorize the use of the actions.
Cognitive Actions Overview
Generate Image With Flux Lora
The Generate Image With Flux Lora action is designed to create images based on specific prompts. It allows for high customization in parameters such as image size, quality, and style, offering features like fast mode and additional LoRA weights for enhanced creativity.
Input
The input schema for this action requires the following fields:
- prompt (required): A textual description that guides the image generation. Example:
"a photo of NEO1X humanoid robot in the sea". - aspectRatio: Specifies the desired aspect ratio for the generated image. Default is
1:1. - outputCount: Determines the number of images to generate, ranging from 1 to 4. Default is 1.
- imageQuality: Sets the quality level for the output images (0-100). Default is 80.
- outputFormat: Specifies the output format of the images (e.g.,
webp,jpg,png). Default iswebp. - loraIntensity: The intensity of the main LoRA model, with a default of 1.
- selectedModel: Specifies which model to use for inference, with a default of
dev. - extraLoraScale: Adjusts the intensity of any additional LoRA models.
- guidanceIntensity: Adjusts the guidance strength during image generation.
- inferenceStepsCount: The number of denoising steps in the diffusion process, with a default of 28.
Here is an example of a JSON payload for the input:
{
"prompt": "a photo of NEO1X humanoid robot in the sea",
"aspectRatio": "3:2",
"outputCount": 1,
"imageQuality": 80,
"outputFormat": "webp",
"loraIntensity": 1,
"selectedModel": "dev",
"extraLoraScale": 0.8,
"guidanceIntensity": 3.5,
"inferenceStepsCount": 28
}
Output
Upon successfully executing this action, you will receive a URL pointing to the generated image. Here's an example of the expected output:
[
"https://assets.cognitiveactions.com/invocations/ae2103cf-3566-48d6-b152-18213cb09d80/11e39f7f-43bd-4592-be48-841266abd9cb.webp"
]
Conceptual Usage Example (Python)
Here's a conceptual Python snippet demonstrating how to call the Generate Image With Flux Lora 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 = "da5f14e6-8893-4888-afd1-621104e243ec" # Action ID for Generate Image With Flux Lora
# Construct the input payload based on the action's requirements
payload = {
"prompt": "a photo of NEO1X humanoid robot in the sea",
"aspectRatio": "3:2",
"outputCount": 1,
"imageQuality": 80,
"outputFormat": "webp",
"loraIntensity": 1,
"selectedModel": "dev",
"extraLoraScale": 0.8,
"guidanceIntensity": 3.5,
"inferenceStepsCount": 28
}
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}
)
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 code, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload is constructed to match the input schema for the action. The response will contain the URL of the generated image, which you can then display or process further.
Conclusion
The fofr/flux-neo-1x Cognitive Action for image generation offers developers a robust way to create customized images based on textual prompts. With features like adjustable quality, aspect ratios, and model selections, you can generate unique visuals tailored to your application's requirements. Explore how this action can enhance your projects, and consider integrating it into your workflow for an innovative image generation experience!