1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import requests
import base64
# Use this function to convert an image file from the filesystem to base64
def image_file_to_base64(image_path):
with open(image_path, 'rb') as f:
image_data = f.read()
return base64.b64encode(image_data).decode('utf-8')
# Use this function to fetch an image from a URL and convert it to base64
def image_url_to_base64(image_url):
response = requests.get(image_url)
image_data = response.content
return base64.b64encode(image_data).decode('utf-8')
api_key = "YOUR_API_KEY"
url = "https://api.segmind.com/v1/cog-video-5b-t2v"
# Request payload
data = {
"prompt": "A golden retriever, sporting sleek black sunglasses, with its lengthy fur flowing in the breeze, sprints playfully across a rooftop terrace, recently refreshed by a light rain. The scene unfolds from a distance, the dog's energetic bounds growing larger as it approaches the camera, its tail wagging with unrestrained joy, while droplets of water glisten on the concrete behind it. The overcast sky provides a dramatic backdrop, emphasizing the vibrant golden coat of the canine as it dashes towards the viewer.",
"negative_prompt": "low quality, blurry",
"input_frames": 49,
"steps": 45,
"guidance_scale": 6,
"seed": 806286757407563,
"frame_rate": 8
}
headers = {'x-api-key': api_key}
response = requests.post(url, json=data, headers=headers)
print(response.content) # The response is the generated image
Text prompt for generating the video
Text to describe what should be avoided in the generated video
Number of input frames for the video generation
min : 16,
max : 60
Number of steps for generating each frame
min : 25,
max : 50
Scale for guidance during generation
min : 5,
max : 10
Seed for random number generation to ensure reproducibility
Frame rate for the video output
min : 8,
max : 10
To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.
Cog Video represents a significant advancement in the field of video generation. This model is designed to convert textual descriptions into high-quality, coherent video sequences, leveraging state-of-the-art deep learning techniques. Cog Video’s architecture is built upon the principles of transformer models, which are known for their efficiency and scalability in handling large datasets and complex tasks.
Text-to-Video Synthesis: Cog Video excels in generating videos from textual inputs, making it a powerful tool for content creators, educators, and entertainment industries.
High-Quality Output: The model produces videos with high resolution and smooth transitions, ensuring a visually appealing output.
Scalability: Built on a robust architecture, Cog Video can handle extensive datasets, making it suitable for large-scale applications.
Versatility: It supports a wide range of video genres and styles, from realistic scenes to animated sequences.
Performance: Demonstrates superior performance in generating coherent and contextually accurate videos from textual descriptions.
Content Creation: Ideal for generating video content for social media, marketing, and educational purposes.
Virtual Reality: Enhances VR experiences by creating immersive video content based on user inputs.
Entertainment: Used in the film and gaming industries to create dynamic and engaging video sequences.
Cog Video sets a new benchmark in the video generation domain, offering unparalleled capabilities and applications. Its innovative approach and robust performance make it a valuable asset for various industries looking to leverage AI for video content creation.