Create Stunning Videos with wcarle/stable-diffusion-videos Cognitive Actions

In the world of creative media, generating dynamic content has never been easier thanks to the capabilities of modern AI. The wcarle/stable-diffusion-videos API allows developers to create mesmerizing videos by interpolating the latent space of Stable Diffusion. With pre-built Cognitive Actions, you can morph between different text prompts and customize various parameters, enhancing the visual storytelling experience.
Prerequisites
Before you dive into using the Cognitive Actions, ensure you have the following:
- An API key from the Cognitive Actions platform.
- Basic knowledge of handling JSON data and making HTTP requests.
- Python environment set up for executing the provided code snippets.
For authentication, you will typically include your API key in the request headers when making calls to the Cognitive Actions endpoint.
Cognitive Actions Overview
Generate Videos From Stable Diffusion
The Generate Videos From Stable Diffusion action allows you to create videos by seamlessly transitioning between different text prompts. You can customize the frame rate, seed values for randomness, and guidance scales to tailor the output to your needs.
Input
This action requires the following inputs, defined in the CompositeRequest schema:
- fps (integer, default: 15): Specifies the frame rate for the video. Acceptable values range from 5 to 60.
- seeds (string): Random seeds for generation, separated by '|'. Leave blank for automatic randomization.
- prompts (string, default: "a cat | a dog | a horse"): Text prompts for generating the video, separated by '|'.
- scheduler (string, default: "klms"): Type of scheduler used in generation. Options include 'default', 'ddim', and 'klms'.
- guidanceScale (number, default: 7.5): Scale for classifier-free guidance, ranging from 1 to 20.
- numberOfSteps (integer, default: 50): Defines the number of steps for generating the interpolation video. Recommended values are 3 or 5 for initial testing, increasing to 60-200 for better quality.
- numberOfInferenceSteps (integer, default: 50): Number of denoising steps for generating each image from the prompt, ranging from 1 to 500.
Here’s an example input for this action:
{
"fps": 15,
"prompts": "a cat | a dog | a horse",
"scheduler": "klms",
"guidanceScale": 7.5,
"numberOfSteps": 50,
"numberOfInferenceSteps": 30
}
Output
Upon successful execution, the action returns a URL pointing to the generated video, for example:
https://assets.cognitiveactions.com/invocations/c0caa3f3-e90a-4477-9290-c7ff7df9953c/af48ba0b-f7fe-4d10-8b27-1568005fdc63.mp4
Conceptual Usage Example (Python)
Here’s how you might invoke the Generate Videos From Stable Diffusion 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 = "633dcf57-9bca-48ed-ac71-aedca86db150" # Action ID for Generate Videos From Stable Diffusion
# Construct the input payload based on the action's requirements
payload = {
"fps": 15,
"prompts": "a cat | a dog | a horse",
"scheduler": "klms",
"guidanceScale": 7.5,
"numberOfSteps": 50,
"numberOfInferenceSteps": 30
}
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 snippet, replace the COGNITIVE_ACTIONS_API_KEY and COGNITIVE_ACTIONS_EXECUTE_URL with your actual values. The action ID corresponds to the Generate Videos From Stable Diffusion action, and the payload is structured according to the input schema. The example illustrates error handling and prints the result upon a successful action execution.
Conclusion
The wcarle/stable-diffusion-videos Cognitive Actions provide a powerful, user-friendly way to create engaging and visually stunning videos. By leveraging the ability to interpolate between text prompts and customize various parameters, developers can unlock new creative possibilities. Explore the potential of these actions and consider how they can enhance your applications in the realm of video generation. Happy coding!