Create Stunning Dance Videos with camenduru/magic-dance Cognitive Actions

The camenduru/magic-dance API provides an innovative solution for generating realistic human dance videos. By leveraging advanced motion transfer techniques, developers can create engaging video content that reflects the desired motions and facial expressions. With just a few pre-built Cognitive Actions, you can easily integrate this functionality into your applications, saving time and effort while enhancing user experience.
Prerequisites
Before getting started with the camenduru/magic-dance API, ensure you have the following:
- An API key for the Cognitive Actions platform. This key will be used to authenticate your requests.
- Basic knowledge of JSON and API integration.
For authentication, you will generally pass your API key in the request headers as a Bearer token.
Cognitive Actions Overview
Generate Dance Video with Motion Transfer
Description: This action generates a realistic dance video by transferring motions and facial expressions from a specified input image using the MagicDance technology.
Category: Video Generation
Input
The input schema for this action includes the following fields:
- imagePath (required): The URL of the input image. This must be a valid URI.
- seed (optional): An integer used for randomness, with a default value of 42.
- poseSequence (optional): A string that indicates the pose sequence. Valid options are '001', '002', or '003', with a default of '001'.
- numTrainingSteps (optional): An integer that defines the number of training steps, which must be between 1 and 5, inclusive, with a default of 1.
Example Input:
{
"seed": 4,
"imagePath": "https://replicate.delivery/pbxt/KPwpjZxbmaIpIwWJjPI9TT5htDT8PuqKIKuekCvZFs98sH2e/CMQVuHLVEAEEHxw.jpg",
"poseSequence": "001",
"numTrainingSteps": 1
}
Output
The output will return the URL of the generated dance video.
Example Output:
https://assets.cognitiveactions.com/invocations/cc0db9ff-13b8-4e4b-901c-94c405cc67cb/45527c03-8759-48ac-88ab-79d4aac305ee.mp4
Conceptual Usage Example (Python)
Below is a conceptual example of how you might invoke the Generate Dance Video with Motion Transfer 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 = "c51334ea-7113-4eba-8be9-02b3dd043620" # Action ID for Generate Dance Video with Motion Transfer
# Construct the input payload based on the action's requirements
payload = {
"seed": 4,
"imagePath": "https://replicate.delivery/pbxt/KPwpjZxbmaIpIwWJjPI9TT5htDT8PuqKIKuekCvZFs98sH2e/CMQVuHLVEAEEHxw.jpg",
"poseSequence": "001",
"numTrainingSteps": 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 code snippet, you replace the API key and endpoint with your actual credentials. The action ID is specified, and the input payload is structured according to the requirements. The response is processed to retrieve the generated video URL.
Conclusion
The camenduru/magic-dance Cognitive Actions empower developers to create captivating dance videos with minimal effort. By using the pre-built action for motion transfer, you can enhance your applications and provide users with delightful experiences. Whether you're building entertainment apps, educational tools, or social media platforms, integrating these capabilities opens up new opportunities for creativity. Explore further and unleash the potential of video generation in your projects!