Create Stunning Images with Flux1 Schnell Multi LoRA

The Flux1 Schnell Multi LoRA service provides developers with powerful Cognitive Actions for image generation. This innovative API allows for the creation of highly customizable images through its support for multi-LoRA, enabling detailed control over various parameters, such as aspect ratio, output format, and prompt strength. With the enhanced performance capabilities of the schnell model, developers can generate images quickly and efficiently, making it an ideal solution for a variety of applications.
Common use cases for this service include generating artwork for games, creating marketing visuals, or producing unique content for social media. By leveraging the capabilities of Flux1 Schnell Multi LoRA, developers can simplify their workflows while delivering high-quality images tailored to specific requirements.
Prerequisites
To use the Flux1 Schnell Multi LoRA service, you will need a valid Cognitive Actions API key and a basic understanding of making API calls.
Generate Image with Multi-LoRA Support
The Generate Image with Multi-LoRA Support action allows you to create images with intricate details and styles by harnessing the power of multiple LoRA models. This action addresses the challenge of producing visually appealing images that meet specific criteria, ensuring a high degree of customization.
Input Requirements
- Prompt: A text description that guides the image generation process.
- Seed: An optional integer to generate reproducible outputs.
- Image: (for image-to-image mode) A URI for an input image to maintain aspect ratio.
- Image Format: Choose from webp, jpg, or png for the output image.
- Image Quality: Define the quality of the output image on a scale from 0 to 100.
- Number of Outputs: Specify how many images to generate (1 to 4).
- Huggingface Loras: A list of URLs to LoRA weights for enhanced image generation.
- Image Aspect Ratio: Specify the desired aspect ratio (e.g., 16:9, 4:3).
- LoRA Weight Scales: Define the scale for LoRA weights for customization.
- Image Prompt Strength: Set the strength of the text prompt.
- Safety Checker Disabled: Option to disable the safety checker if needed.
- Number of Inference Steps: Control the number of inference steps (1 to 4).
Expected Output
The expected output is a URL to the generated image, which can be used directly in applications or displayed on websites.
Use Cases for this specific action:
- Creative Projects: Ideal for artists and designers looking to generate unique visuals based on descriptive prompts.
- Game Development: Generate character designs or landscapes quickly to prototype game ideas.
- Marketing Campaigns: Create customized promotional images that align with brand messaging.
- Social Media Content: Produce eye-catching images for posts and advertisements.
import requests
import json
# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"
action_id = "640eb745-8e32-4817-826a-ff315a79f193" # Action ID for: Generate Image with Multi-LoRA Support
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"seed": 43,
"prompt": "a beautiful scandinavian girl posing in the mountains, the sun is shining, the grass is green and flowers are everywhere, she is wearing a patterned colorful top. be4u7y",
"imageFormat": "webp",
"imageQuality": 100,
"numberOfOutputs": 1,
"huggingfaceLoras": [
"https://huggingface.co/Octree/flux-schnell-lora/resolve/main/flux-schnell-lora.safetensors",
"https://huggingface.co/hugovntr/flux-schnell-realism/resolve/main/schnell-realism_v1.safetensors"
],
"imageAspectRatio": "1:1",
"loraWeightScales": [
0.8,
0.9
],
"imagePromptStrength": 0.8,
"diffusionGuidanceScale": 0,
"numberOfInferenceSteps": 4
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json",
# Add any other required headers for the Cognitive Actions API
}
# Prepare the request body for the hypothetical execution endpoint
request_body = {
"action_id": action_id,
"inputs": payload
}
print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json=request_body
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully. Result:")
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 (non-JSON): {e.response.text}")
print("------------------------------------------------")
Conclusion
The Flux1 Schnell Multi LoRA service offers developers a robust solution for generating high-quality images tailored to specific needs. With its customizable parameters and multi-LoRA support, it simplifies the image creation process, making it suitable for various applications, from creative projects to marketing efforts.
To get started, obtain your API key and explore how you can integrate these powerful cognitive actions into your projects!