Create Stunning Videos with Wan2.1 Lora Models

In the realm of content creation, the demand for high-quality video production continues to rise. Enter "Wan2.1 With Lora," a powerful tool designed to help developers generate captivating video content effortlessly. By leveraging the capabilities of the Wan2.1 models alongside LORA (Low-Rank Adaptation), this service allows for the creation of videos that not only meet the needs for speed and efficiency but also enhance visual quality. Whether you're crafting animations for social media, promotional videos for businesses, or educational content, the flexibility and customization options provided by this service make it an invaluable resource.
Prerequisites
To get started with Wan2.1 With Lora, you'll need access to a Cognitive Actions API key and a basic understanding of how to make API calls.
Generate Video with Wan2.1 Lora Models
The primary action available through Wan2.1 With Lora is the ability to generate video content using the Wan2.1 models enhanced by LORA. This action is pivotal in creating high-quality and visually appealing videos tailored to your specific requirements.
Purpose
This action allows developers to create video content by specifying various parameters, such as model version, number of frames, aspect ratio, and more. It addresses the common challenge of producing video content quickly while maintaining high visual fidelity.
Input Requirements
The input for this action is a structured object that includes several properties:
- prompt (string): A descriptive text prompt that guides the content of the video.
- model (string): Choose between "1.3b" for faster generation or "14b" for superior quality.
- frames (integer): Specify the number of frames for the video, affecting its duration.
- aspectRatio (string): Define the video's aspect ratio (16:9, 9:16, or 1:1).
- loraUrl (string, optional): A URL to a LORA file for enhanced video generation.
- sampleShift (number): A factor influencing the sampling process.
- sampleSteps (integer): The number of steps for the generation process.
- loraStrengthClip (number): Intensity of LORA application on the CLIP model.
- sampleGuideScale (number): Controls adherence to the prompt.
- loraStrengthModel (number): Defines how strongly LORA is applied to the primary model.
- negativePrompt (string, optional): Specify elements to avoid in the video output.
Expected Output
The output of this action is a URL linking to the generated video file. For example:
- Output:
["https://assets.cognitiveactions.com/invocations/.../video.mp4"]
Use Cases for this Specific Action
- Marketing & Advertising: Create visually engaging promotional videos for products or services that capture audience attention effectively.
- Social Media Content: Generate quick and dynamic video animations for platforms like Instagram, TikTok, or YouTube, tailored to trending themes.
- Educational Videos: Develop instructional content with animated visuals that enhance learning experiences for viewers.
- Creative Projects: Support artists and creators in visual storytelling by producing high-quality video narratives based on their prompts.
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 = "fdfdec5d-898e-494c-b093-eb910ee7170d" # Action ID for: Generate Video with Wan2.1 Lora Models
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"model": "14b",
"frames": 81,
"prompt": "flat color 2d animation of a portrait of woman with white hair and green eyes, dynamic scene",
"loraUrl": "https://huggingface.co/motimalu/wan-flat-color-v2/resolve/main/wan_flat_color_v2.safetensors",
"aspectRatio": "16:9",
"sampleShift": 8,
"sampleSteps": 30,
"loraStrengthClip": 1,
"sampleGuideScale": 5,
"loraStrengthModel": 1
}
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 Wan2.1 With Lora service empowers developers to produce high-quality video content rapidly and efficiently. By leveraging the flexibility of model selection and customizable parameters, you can cater to a variety of use cases ranging from marketing to education. With these capabilities at your disposal, the next step is to explore how you can integrate this powerful video generation tool into your projects, enhancing your creative output and engaging your audience like never before.