Generate Stunning Videos from Images Using the fofr/wan-0_1-webp Cognitive Actions

In the world of multimedia content creation, the ability to generate videos from static images can elevate user engagement and creativity. The fofr/wan-0_1-webp Cognitive Actions empower developers to harness the power of AI to create high-quality video content efficiently. Utilizing advanced models fine-tuned specifically for character generation, these actions are designed to simplify the video creation process while offering a range of customization options.
Prerequisites
Before diving into the integration of these Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform. This key will be necessary for authentication when making requests to the API.
- Basic knowledge of JSON structure and Python programming for handling API requests.
Authentication typically involves passing your API key in the headers of your requests, allowing you to securely access the services provided by the Cognitive Actions.
Cognitive Actions Overview
Generate Video from Image
The Generate Video from Image action utilizes the advanced Wan 14b model to create dynamic video content from a still image, guided by a customizable text prompt. This action falls under the video-generation category and supports various parameters for tailored video output, including frame count, resolution, and aspect ratio.
Input
The input for this action requires a JSON object with the following fields:
- prompt (required): A text description that guides the video content. (Example: "0_1 woman is laughing")
- image (optional): The URL of the image that will serve as the initial frame for the video.
- frameCount (optional): Number of frames to generate, corresponding to video lengths of 1 to 5 seconds. (Default: 81)
- guidanceScale (optional): Numeric value indicating how closely the video should adhere to the prompt. (Default: 5)
- exclusionPrompt (optional): Specifies elements to avoid in the video.
- generationSteps (optional): The number of steps for video generation, with a recommended default of 30.
- videoResolution (optional): Selects the video's resolution (e.g., "480p", "720p"; note 720p is incompatible with certain models).
- videoAspectRatio (optional): Specifies the aspect ratio (e.g., "16:9", "9:16", "1:1").
- customWeights, sampleAdjustment, clipStrengthFactor, modelStrengthFactor, and generationSpeedMode are also optional fields that allow for further customization.
Here’s an example JSON payload for invoking this action:
{
"prompt": "0_1 woman is laughing",
"frameCount": 81,
"guidanceScale": 5,
"exclusionPrompt": "",
"generationSteps": 30,
"sampleAdjustment": 8,
"videoAspectRatio": "9:16",
"clipStrengthFactor": 1,
"modelStrengthFactor": 1
}
Output
Upon successful execution, the action returns a URL pointing to the generated video. Here’s an example of the output:
[
"https://assets.cognitiveactions.com/invocations/ace98475-727c-43bc-9681-d6bfb1790e7c/23beb4b8-edfd-4c9b-854a-65e8d0d406c7.mp4"
]
Conceptual Usage Example (Python)
Here's a conceptual Python code snippet illustrating how a developer might call the Generate Video from Image action:
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 = "19ed9b50-4bc2-44be-95b1-657c5c716257" # Action ID for Generate Video from Image
# Construct the input payload based on the action's requirements
payload = {
"prompt": "0_1 woman is laughing",
"frameCount": 81,
"guidanceScale": 5,
"exclusionPrompt": "",
"generationSteps": 30,
"sampleAdjustment": 8,
"videoAspectRatio": "9:16",
"clipStrengthFactor": 1,
"modelStrengthFactor": 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:
- Replace
YOUR_COGNITIVE_ACTIONS_API_KEYwith your actual API key. - The
action_idcorresponds to the specific action you are invoking. - The
payloadcontains the structured input as per the action's schema.
Conclusion
The Generate Video from Image action within the fofr/wan-0_1-webp Cognitive Actions provides developers with a robust tool for creating high-quality video content from images. With flexible input options and easy integration, this action can enhance multimedia applications, making them more engaging and visually appealing. Consider exploring further customization options to perfect the video output for your specific use cases!