Create Unique Videos from Text with Hunyuan Video LoRA Cognitive Actions

In recent years, the demand for engaging video content has surged, making video generation technologies increasingly valuable. The Hunyuan Video LoRA Cognitive Actions provide developers with the ability to create personalized videos from text descriptions, enabling unique style adaptations and model training. This powerful capability allows for tailored video outputs, enhancing user engagement and creativity in applications.
Prerequisites
Before you begin using the Hunyuan Video LoRA Cognitive Actions, 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, as you will be constructing input payloads in JSON format.
To authenticate your API requests, you will typically pass your API key in the headers of your HTTP requests.
Cognitive Actions Overview
Generate Custom Text-to-Video with Hunyuan LoRA
The Generate Custom Text-to-Video with Hunyuan LoRA action allows you to create personalized videos from detailed text prompts using the HunyuanVideo model. This action supports customizable LoRA (Low-Rank Adaptation) files for unique video styles.
Input
The input schema for this action is detailed below. You can specify various parameters to control the video generation process:
{
"seed": 12345,
"steps": 30,
"width": 512,
"height": 512,
"prompt": "In the style of RSNG. A woman with blonde hair stands on a balcony at night, framed against a backdrop of city lights. She wears a white crop top and a dark jacket, exuding a confident presence as she gazes directly at the camera",
"flowShift": 9,
"frameRate": 15,
"scheduler": "DPMSolverMultistepScheduler",
"crfQuality": 19,
"loraFileUrl": "lucataco/hunyuan-musubi-rose-6",
"forceOffload": true,
"loraStrength": 1,
"guidanceScale": 6,
"enhancementEnd": 1,
"numberOfFrames": 33,
"denoiseStrength": 1,
"enhancementStart": 0,
"enhancementStrength": 0.3,
"applyEnhancementAcrossPairs": true,
"applyEnhancementToIndividual": true
}
- Seed: Set a seed for reproducibility (optional).
- Steps: Number of diffusion steps (default: 50, range: 1 to 150).
- Width: Width of the generated video (default: 640 pixels, range: 64 to 1536).
- Height: Height of the generated video (default: 360 pixels, range: 64 to 1024).
- Prompt: Description of the video scene (required).
- Flow Shift: Continuity factor for video flow (default: 9, range: 0 to 20).
- Frame Rate: Frames per second (default: 16, range: 1 to 60).
- Scheduler: Algorithm used for video frame generation (default: "DPMSolverMultistepScheduler").
- CRF Quality: Affects video compression quality (default: 19, range: 0 to 51).
- LoRA File URL: URL pointing to a LoRA .safetensors file (required).
- Force Offload: Whether to offload model layers to CPU (default: true).
- LoRA Strength: Scale of the LoRA (default: 1, range: -10 to 10).
- Guidance Scale: Balance between text and model guidance (default: 6, range: 0 to 30).
- Enhancement Start/End: Specifies when to start/end the enhancement effect.
- Number of Frames: How many frames in the resulting video (default: 33, range: 1 to 1440).
- Denoise Strength: Level of noise applied (default: 1, range: 0 to 2).
- Enhancement Strength: Intensity of the enhancement effect (default: 0.3, range: 0 to 2).
- Apply Enhancement Across Pairs: Apply enhancement across frame pairs (default: true).
- Apply Enhancement To Individual: Apply enhancement to individual frames (default: true).
Output
Upon successful execution, this action returns a URL pointing to the generated video. Here’s an example of a typical output:
https://assets.cognitiveactions.com/invocations/5fbca185-9cee-49d9-b4d7-fe7da0ee259c/8f88ac92-ba3a-4055-9eaa-934f2c958211.mp4
Conceptual Usage Example (Python)
Here’s how you might call this action using a hypothetical Cognitive Actions execution endpoint in Python:
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 = "f320c8a6-5382-473c-933e-a1d74e18488b" # Action ID for Generate Custom Text-to-Video
# Construct the input payload based on the action's requirements
payload = {
"steps": 30,
"width": 512,
"height": 512,
"prompt": "In the style of RSNG. A woman with blonde hair stands on a balcony at night, framed against a backdrop of city lights. She wears a white crop top and a dark jacket, exuding a confident presence as she gazes directly at the camera",
"flowShift": 9,
"frameRate": 15,
"scheduler": "DPMSolverMultistepScheduler",
"crfQuality": 19,
"loraFileUrl": "lucataco/hunyuan-musubi-rose-6",
"forceOffload": true,
"loraStrength": 1,
"guidanceScale": 6,
"enhancementEnd": 1,
"numberOfFrames": 33,
"denoiseStrength": 1,
"enhancementStart": 0,
"enhancementStrength": 0.3,
"applyEnhancementAcrossPairs": true,
"applyEnhancementToIndividual": true
}
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 code snippet, you will set the action ID and construct the input payload according to the specified schema. The endpoint URL and request structure are illustrative; make sure to replace them with actual values as needed.
Conclusion
Utilizing the Hunyuan Video LoRA Cognitive Actions enables developers to generate captivating and unique video content from text prompts. This not only enhances user experience but also opens up numerous creative possibilities for applications. Experiment with various parameters to fine-tune video outputs to suit your needs, and start integrating these powerful actions into your projects today!