Create Stunning Animated Videos with zsxkib/animatediff-illusions Cognitive Actions

In the realm of video generation, the zsxkib/animatediff-illusions Cognitive Actions provide a powerful way to create animated videos that captivate audiences. Leveraging advanced technologies such as ControlNet and AnimateDiff, these actions allow developers to generate high-quality, loopable animations with ease. In this guide, we will explore how to integrate the "Generate Animated Video with ControlNet QR Code" action into your applications, focusing on its capabilities and practical usage.
Prerequisites
To get started with the Cognitive Actions from the zsxkib/animatediff-illusions specification, you'll need the following:
- An API key for the Cognitive Actions platform.
- Basic knowledge of JSON and Python for integration.
Authentication typically involves passing your API key in the headers of your requests. Ensure you have your API key handy as we proceed.
Cognitive Actions Overview
Generate Animated Video with ControlNet QR Code
Purpose
This action creates animated videos using Monster Labs' ControlNet QR Code Monster v2. By incorporating QR code keyframes and dynamic prompts with Motion Module SD 1.5 v2, it utilizes AnimateDiff technology to produce high-quality, loopable animations.
Input
The input schema for this action includes various fields that allow you to customize the video generation process. Here’s a brief overview:
- loop (boolean): Indicates whether the video should loop continuously. Default is
true. - seed (integer): Seed used for image generation to ensure reproducibility. A negative or omitted value randomizes the seed.
- steps (integer): Number of inference steps in the generation process, default is 25.
- width (integer): Width of the generated video in pixels. Must be divisible by 8 (default is 256).
- frames (integer): Total length of the video in frames; playback occurs at 8 fps.
- height (integer): Height of the generated video in pixels, also must be divisible by 8 (default is 384).
- promptMap (string): Specifies changes in animation using a format like
'frame number: prompt at this frame'. - outputFormat (string): Specifies the output format of the video; options include
'mp4'and'gif'.
Here is an example of the JSON payload that you would use to invoke this action:
{
"loop": true,
"seed": -1,
"steps": 25,
"width": 384,
"frames": 32,
"height": 256,
"context": 16,
"clipSkip": 2,
"baseModel": "majicmixRealistic_v5Preview",
"promptMap": "0: rolling waves",
"scheduler": "k_dpmpp_sde",
"headPrompt": "a beautiful ocean",
"tailPrompt": "flashes of lightning, eerie, mysterious",
"outputFormat": "mp4",
"guidanceScale": 7.5,
"negativePrompt": "ugly, broken",
"controlNetVideo": "https://replicate.delivery/pbxt/JlbPomk5xQXYw3Mao6B9eoFJS0moaYjCGSRhFPcMLCXNu0w8/spiral.gif",
"qrCodeModeGuessing": false,
"videoInterpolation": true,
"activateQRCodeModeV2": true,
"conditioningStrength": 0.25,
"promptStabilityRatio": 0.5,
"videoFramesPerSecond": 16,
"interpolationStepsCount": 3,
"qrCodeFramePreprocessor": true
}
Output
Upon successful execution, this action typically returns a URL to the generated video. For example:
{
"output": "https://assets.cognitiveactions.com/invocations/6e1e3c4a-4d7a-48be-8ce3-44648ede9246/c689f81d-cce5-41fb-98c0-7828f2a6bce6.mp4"
}
Conceptual Usage Example (Python)
Here is a conceptual Python code snippet to help you call this action using a hypothetical Cognitive Actions execution endpoint:
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 = "04a0e276-717a-4840-8234-64f398434c33" # Action ID for Generate Animated Video with ControlNet QR Code
# Construct the input payload based on the action's requirements
payload = {
"loop": true,
"seed": -1,
"steps": 25,
"width": 384,
"frames": 32,
"height": 256,
"context": 16,
"clipSkip": 2,
"baseModel": "majicmixRealistic_v5Preview",
"promptMap": "0: rolling waves",
"scheduler": "k_dpmpp_sde",
"headPrompt": "a beautiful ocean",
"tailPrompt": "flashes of lightning, eerie, mysterious",
"outputFormat": "mp4",
"guidanceScale": 7.5,
"negativePrompt": "ugly, broken",
"controlNetVideo": "https://replicate.delivery/pbxt/JlbPomk5xQXYw3Mao6B9eoFJS0moaYjCGSRhFPcMLCXNu0w8/spiral.gif",
"qrCodeModeGuessing": false,
"videoInterpolation": true,
"activateQRCodeModeV2": true,
"conditioningStrength": 0.25,
"promptStabilityRatio": 0.5,
"videoFramesPerSecond": 16,
"interpolationStepsCount": 3,
"qrCodeFramePreprocessor": 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}
)
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, you replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable contains the input JSON structure based on the action's requirements. This snippet demonstrates how to make a POST request to the hypothetical endpoint, handle responses, and print results.
Conclusion
The zsxkib/animatediff-illusions Cognitive Actions empower developers to create stunning animated videos effortlessly. By utilizing the capabilities of the "Generate Animated Video with ControlNet QR Code" action, you can enhance your applications with dynamic visual content. Start integrating these actions today to elevate your projects and explore the creative possibilities that animated video generation offers!