Generate Stunning Videos with Hunyuan Cognitive Actions

24 Apr 2025
Generate Stunning Videos with Hunyuan Cognitive Actions

In this article, we'll explore the "fofr/hunyuan-take-on-me" Cognitive Actions, specifically focusing on the powerful capability to generate video clips using the Hunyuan model. This model has been fine-tuned on iconic 3-second clips from A-ha's classic "Take on Me" music video, allowing developers to create sketched animations based on customizable parameters. By leveraging these pre-built actions, developers can integrate unique video generation features into their applications without needing to build complex models from scratch.

Prerequisites

To get started with these Cognitive Actions, you will need an API key from the Cognitive Actions platform. This key will be used to authenticate your requests. Typically, you would include this API key in the headers of your HTTP requests. Ensure you have a development environment set up with access to Python and the requests library for making API calls.

Cognitive Actions Overview

Generate Video with Hunyuan Model

Description: This action allows you to generate video clips using the Hunyuan model. You can customize parameters like video dimensions, frame rate, and style through a text prompt, enabling the creation of unique sketched animations.

Category: Video Generation

Input: The input schema is structured as follows:

{
  "steps": 50,
  "width": 640,
  "height": 360,
  "prompt": "In the style of TKONME, this video sequence is a sketched animations depicting a young woman with hair in a bun and loose strands, she looks up.",
  "frameRate": 24,
  "frameCount": 85,
  "loraFileUrl": "",
  "forceOffload": true,
  "guidanceScale": 6,
  "loraIntensity": 0.85,
  "videoQualityFactor": 19,
  "videoContinuityFactor": 9,
  "noiseReductionIntensity": 1
}
  • steps (integer): Number of diffusion steps (default: 50, range: 1-150).
  • width (integer): Width of the output video in pixels (default: 640, range: 64-1536).
  • height (integer): Height of the output video in pixels (default: 360, range: 64-1024).
  • prompt (string): Text description influencing the video's visual content.
  • frameRate (integer): Frame rate for the video (default: 24, range: 1-60).
  • frameCount (integer): Total number of frames in the video (default: 85, range: 1-300).
  • loraFileUrl (string): URL for a LoRA .safetensors file (optional).
  • forceOffload (boolean): Whether to forcefully offload model layers to CPU (default: true).
  • guidanceScale (number): Strength of guidance balancing (default: 6).
  • loraIntensity (number): Intensity of the LoRA application (default: 0.85).
  • weightFileUri (string): URI for a tar file containing LoRA weights (optional).
  • videoQualityFactor (integer): Constant Rate Factor for video encoding quality (default: 19, range: 0-51).
  • videoContinuityFactor (integer): Flow control for video continuity (default: 9, range: 0-20).
  • noiseReductionIntensity (number): Strength of denoise applied (default: 1).

Example Input:

{
    "steps": 50,
    "width": 640,
    "height": 360,
    "prompt": "In the style of TKONME, this video sequence is a sketched animations depicting a young woman with hair in a bun and loose strands, she looks up.",
    "frameRate": 24,
    "frameCount": 85,
    "loraFileUrl": "",
    "forceOffload": true,
    "guidanceScale": 6,
    "loraIntensity": 0.85,
    "videoQualityFactor": 19,
    "videoContinuityFactor": 9,
    "noiseReductionIntensity": 1
}

Output: Upon successful execution, this action returns a URL to the generated video. For example:

https://assets.cognitiveactions.com/invocations/00314e57-ba81-497b-ba1b-035ffa3ad63b/2e50e116-83a7-4256-9caa-d1c615373819.mp4

Conceptual Usage Example (Python): Here’s how you might call this action using 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 = "f363f9e6-5119-4877-89dc-ee9d6a56e643"  # Action ID for Generate Video with Hunyuan Model

# Construct the input payload based on the action's requirements
payload = {
    "steps": 50,
    "width": 640,
    "height": 360,
    "prompt": "In the style of TKONME, this video sequence is a sketched animations depicting a young woman with hair in a bun and loose strands, she looks up.",
    "frameRate": 24,
    "frameCount": 85,
    "loraFileUrl": "",
    "forceOffload": True,
    "guidanceScale": 6,
    "loraIntensity": 0.85,
    "videoQualityFactor": 19,
    "videoContinuityFactor": 9,
    "noiseReductionIntensity": 1
}

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, you replace the Cognitive Actions API key and the action_id with the appropriate values. The code constructs the input payload based on the schema and sends a POST request to the execution endpoint, handling responses and potential errors.

Conclusion

The Hunyuan Cognitive Actions empower developers to create captivating video content effortlessly. By leveraging the "Generate Video with Hunyuan Model" action, you can produce unique animations tailored to your requirements. Explore the potential of these actions to enhance your applications, engage users, and bring creative visions to life. Start integrating these capabilities today and watch your projects come alive with stunning visual content!