### Launch Local Gradio Demo Source: https://github.com/ailab-cvc/videocrafter/blob/main/README.md Run this command to start the local Gradio web application for VideoCrafter. Ensure all pretrained models are downloaded and placed correctly. ```python python gradio_app.py ``` -------------------------------- ### Install Environment via Anaconda Source: https://github.com/ailab-cvc/videocrafter/blob/main/README.md Use this command to create and activate a new conda environment for VideoCrafter. Ensure you have Anaconda installed. ```bash conda create -n videocrafter python=3.8.5 conda activate videocrafter pip install -r requirements.txt ``` -------------------------------- ### Download VideoCrafter Models from Hugging Face Source: https://context7.com/ailab-cvc/videocrafter/llms.txt Use this Python function to download all required VideoCrafter models. It checks if models already exist locally before downloading to avoid redundant downloads. Ensure you have the `huggingface_hub` library installed. ```python from huggingface_hub import hf_hub_download import os def download_videocrafter_models(): """ Download all VideoCrafter models from Hugging Face Hub. """ models = { 'T2V-512-v2': { 'repo_id': 'VideoCrafter/VideoCrafter2', 'filename': 'model.ckpt', 'local_dir': './checkpoints/base_512_v2/' }, 'I2V-512-v1': { 'repo_id': 'VideoCrafter/Image2Video-512', 'filename': 'model.ckpt', 'local_dir': './checkpoints/i2v_512_v1/' }, 'T2V-512-v1': { 'repo_id': 'VideoCrafter/Text2Video-512', 'filename': 'model.ckpt', 'local_dir': './checkpoints/base_512_v1/' }, 'T2V-1024-v1': { 'repo_id': 'VideoCrafter/Text2Video-1024', 'filename': 'model.ckpt', 'local_dir': './checkpoints/base_1024_v1/' } } for name, info in models.items(): local_dir = info['local_dir'] local_file = os.path.join(local_dir, info['filename']) if not os.path.exists(local_file): os.makedirs(local_dir, exist_ok=True) print(f'Downloading {name}...') ``` ```python hf_hub_download( repo_id=info['repo_id'], filename=info['filename'], local_dir=local_dir, local_dir_use_symlinks=False ) print(f'Downloaded to {local_file}') else: print(f'{name} already exists at {local_file}') # Download all models download_videocrafter_models() ``` -------------------------------- ### Run Image-to-Video Inference Source: https://github.com/ailab-cvc/videocrafter/blob/main/README.md Execute this script after downloading the pretrained Image-to-Video models and placing the checkpoint file in the specified directory. ```bash sh scripts/run_image2video.sh ``` -------------------------------- ### Run Text-to-Video Inference Source: https://github.com/ailab-cvc/videocrafter/blob/main/README.md Execute this script after downloading the pretrained Text-to-Video models and placing the checkpoint file in the specified directory. ```bash sh scripts/run_text2video.sh ``` -------------------------------- ### Image-to-Video Generation (Command Line) Source: https://context7.com/ailab-cvc/videocrafter/llms.txt Transform static images into dynamic videos with text-guided motion using the command-line inference script. ```APIDOC ## POST /api/videocrafter/i2v ### Description Transform static images into dynamic videos with text-guided motion using the inference script. ### Method POST ### Endpoint /api/videocrafter/i2v ### Parameters #### Query Parameters - **seed** (integer) - Optional - Seed for random number generation. - **mode** (string) - Required - Generation mode, typically 'i2v' for image-to-video. - **ckpt_path** (string) - Required - Path to the checkpoint file for the I2V model. - **config** (string) - Required - Path to the configuration YAML file for inference. - **savedir** (string) - Required - Directory to save the generated videos. - **n_samples** (integer) - Optional - Number of samples to generate. - **bs** (integer) - Optional - Batch size for generation. - **height** (integer) - Optional - Height of the generated video. - **width** (integer) - Optional - Width of the generated video. - **unconditional_guidance_scale** (float) - Optional - Classifier-free guidance scale. - **ddim_steps** (integer) - Optional - Number of DDIM sampling steps. - **ddim_eta** (float) - Optional - DDIM eta for stochasticity. - **prompt_file** (string) - Required - Path to a text file containing video prompts. - **cond_input** (string) - Required - Directory containing input images or videos. - **fps** (integer) - Optional - Frames per second for the generated video. ### Request Example ```bash python3 scripts/evaluation/inference.py \ --seed 123 \ --mode 'i2v' \ --ckpt_path checkpoints/i2v_512_v1/model.ckpt \ --config configs/inference_i2v_512_v1.0.yaml \ --savedir results/i2v_output \ --n_samples 1 \ --bs 1 \ --height 320 \ --width 512 \ --unconditional_guidance_scale 12.0 \ --ddim_steps 50 \ --ddim_eta 1.0 \ --prompt_file prompts/i2v_prompts/test_prompts.txt \ --cond_input prompts/i2v_prompts \ --fps 8 ``` ### Response #### Success Response (200) - **video_paths** (array) - List of paths to the generated video files. #### Response Example ```json { "video_paths": ["results/i2v_output/0001.mp4"] } ``` ``` -------------------------------- ### Image-to-Video Generation (CLI) Source: https://context7.com/ailab-cvc/videocrafter/llms.txt Transform static images into dynamic videos using the image-to-video inference script. Specify the directory containing input images and corresponding text prompts. ```bash python3 scripts/evaluation/inference.py \ --seed 123 \ --mode 'i2v' \ --ckpt_path checkpoints/i2v_512_v1/model.ckpt \ --config configs/inference_i2v_512_v1.0.yaml \ --savedir results/i2v_output \ --n_samples 1 \ --bs 1 \ --height 320 \ --width 512 \ --unconditional_guidance_scale 12.0 \ --ddim_steps 50 \ --ddim_eta 1.0 \ --prompt_file prompts/i2v_prompts/test_prompts.txt \ --cond_input prompts/i2v_prompts \ --fps 8 ``` -------------------------------- ### Text-to-Video Generation (CLI) Source: https://context7.com/ailab-cvc/videocrafter/llms.txt Generate videos from text prompts using the command-line inference script. Ensure model checkpoints and configuration files are correctly specified. ```bash python3 scripts/evaluation/inference.py \ --seed 123 \ --mode 'base' \ --ckpt_path checkpoints/base_512_v2/model.ckpt \ --config configs/inference_t2v_512_v2.0.yaml \ --savedir results/my_videos \ --n_samples 1 \ --bs 1 \ --height 320 \ --width 512 \ --unconditional_guidance_scale 12.0 \ --ddim_steps 50 \ --ddim_eta 1.0 \ --prompt_file prompts/test_prompts.txt \ --fps 28 ``` -------------------------------- ### Launch Gradio Web Interface Source: https://context7.com/ailab-cvc/videocrafter/llms.txt Launches an interactive Gradio web UI for text-to-video generation. This can be run directly from the terminal or programmatically. ```python # Method 1: Run the Gradio app directly # Terminal command: # python gradio_app.py # Method 2: Programmatic launch import gradio as gr from scripts.gradio.t2v_test import Text2Video def videocrafter_demo(result_dir='./tmp/'): text2video = Text2Video(result_dir) with gr.Blocks() as demo: gr.Markdown("## VideoCrafter2: Text-to-Video Generation") with gr.Row(): with gr.Column(): input_text = gr.Text(label='Prompt') steps = gr.Slider(1, 60, value=50, step=1, label='Sampling Steps') cfg_scale = gr.Slider(1.0, 30.0, value=12.0, step=0.5, label='CFG Scale') eta = gr.Slider(0.0, 1.0, value=1.0, step=0.1, label='ETA') fps = gr.Slider(4, 32, value=16, step=1, label='FPS') btn = gr.Button("Generate Video") with gr.Column(): output_video = gr.Video(label='Generated Video') btn.click( fn=text2video.get_prompt, inputs=[input_text, steps, cfg_scale, eta, fps], outputs=[output_video] ) return demo # Launch the interface demo = videocrafter_demo('./results/') demo.queue(concurrency_count=1, max_size=10) demo.launch(server_name='0.0.0.0', server_port=7860) # Access at: http://localhost:7860 ``` -------------------------------- ### Load VideoCrafter Model from Checkpoint Source: https://context7.com/ailab-cvc/videocrafter/llms.txt Loads a VideoCrafter model using its configuration and checkpoint paths. Ensures the model is set to evaluation mode and moved to the specified device. ```python from omegaconf import OmegaConf from utils.utils import instantiate_from_config from scripts.evaluation.funcs import load_model_checkpoint import torch def load_videocrafter_model(config_path, checkpoint_path, device='cuda'): """ Load VideoCrafter model from config and checkpoint. Args: config_path: Path to YAML config file checkpoint_path: Path to model checkpoint (.ckpt) device: Target device ('cuda' or 'cpu') Returns: Loaded model in eval mode """ # Load configuration config = OmegaConf.load(config_path) model_config = config.pop("model", OmegaConf.create()) # Disable gradient checkpointing for inference model_config['params']['unet_config']['params']['use_checkpoint'] = False # Instantiate model model = instantiate_from_config(model_config) # Load checkpoint model = load_model_checkpoint(model, checkpoint_path) model = model.to(device) model.eval() return model # Load T2V model t2v_model = load_videocrafter_model( config_path='configs/inference_t2v_512_v2.0.yaml', checkpoint_path='checkpoints/base_512_v2/model.ckpt' ) # Load I2V model i2v_model = load_videocrafter_model( config_path='configs/inference_i2v_512_v1.0.yaml', checkpoint_path='checkpoints/i2v_512_v1/model.ckpt' ) # Model info print(f"Temporal length: {t2v_model.temporal_length}") # 16 frames print(f"Latent channels: {t2v_model.channels}") # 4 print(f"Image size: {t2v_model.image_size}") # [40, 64] ``` -------------------------------- ### Text-to-Video Generation (Command Line) Source: https://context7.com/ailab-cvc/videocrafter/llms.txt Generate videos from text prompts using the command-line inference script. This script allows for detailed configuration of generation parameters. ```APIDOC ## POST /api/videocrafter/t2v ### Description Generate videos from text prompts using the inference script with configurable parameters. ### Method POST ### Endpoint /api/videocrafter/t2v ### Parameters #### Query Parameters - **seed** (integer) - Optional - Seed for random number generation. - **mode** (string) - Required - Generation mode, typically 'base' for T2V. - **ckpt_path** (string) - Required - Path to the checkpoint file for the T2V model. - **config** (string) - Required - Path to the configuration YAML file for inference. - **savedir** (string) - Required - Directory to save the generated videos. - **n_samples** (integer) - Optional - Number of samples to generate. - **bs** (integer) - Optional - Batch size for generation. - **height** (integer) - Optional - Height of the generated video. - **width** (integer) - Optional - Width of the generated video. - **unconditional_guidance_scale** (float) - Optional - Classifier-free guidance scale. - **ddim_steps** (integer) - Optional - Number of DDIM sampling steps. - **ddim_eta** (float) - Optional - DDIM eta for stochasticity. - **prompt_file** (string) - Required - Path to a text file containing video prompts. - **fps** (integer) - Optional - Frames per second for the generated video. ### Request Example ```bash python3 scripts/evaluation/inference.py \ --seed 123 \ --mode 'base' \ --ckpt_path checkpoints/base_512_v2/model.ckpt \ --config configs/inference_t2v_512_v2.0.yaml \ --savedir results/my_videos \ --n_samples 1 \ --bs 1 \ --height 320 \ --width 512 \ --unconditional_guidance_scale 12.0 \ --ddim_steps 50 \ --ddim_eta 1.0 \ --prompt_file prompts/test_prompts.txt \ --fps 28 ``` ### Response #### Success Response (200) - **video_paths** (array) - List of paths to the generated video files. #### Response Example ```json { "video_paths": ["results/my_videos/0001.mp4", "results/my_videos/0002.mp4"] } ``` ``` -------------------------------- ### DDIM Sampling Configuration Source: https://context7.com/ailab-cvc/videocrafter/llms.txt Configure DDIM sampler parameters for customized video generation. Adjust steps, guidance scale, and eta for speed and quality trade-offs. ```python from lvdm.models.samplers.ddim import DDIMSampler import torch # Assuming model is already loaded # ddim_sampler = DDIMSampler(model) # DDIM Sampler parameters: # S: Number of DDIM steps (fewer = faster, more = higher quality) # batch_size: Number of videos to generate simultaneously # shape: Latent shape [channels, temporal_frames, height, width] # conditioning: Text embeddings from CLIP encoder # eta: 0.0 = deterministic, 1.0 = stochastic (DDPM-like) # unconditional_guidance_scale: CFG scale (higher = stronger text adherence) # temperature: Noise temperature (default: 1.0) # Example sampling configuration sampling_config = { 'S': 50, # DDIM steps 'batch_size': 1, 'shape': (4, 16, 40, 64), # [C, T, H, W] in latent space 'eta': 1.0, # Stochasticity 'unconditional_guidance_scale': 12.0, # CFG scale 'temperature': 1.0, 'noise_dropout': 0.0, 'verbose': True } # For faster generation (lower quality): fast_config = {'S': 25, 'unconditional_guidance_scale': 7.5, 'eta': 0.0} # For higher quality (slower): quality_config = {'S': 100, 'unconditional_guidance_scale': 15.0, 'eta': 1.0} ``` -------------------------------- ### Generate Video from Image Source: https://context7.com/ailab-cvc/videocrafter/llms.txt Use the `get_image` method to generate a video from a NumPy image array and a text prompt. Adjust sampling steps, CFG scale, eta, and FPS for desired output. ```python # image: NumPy array of shape (H, W, 3) in RGB format # prompt: Text description guiding the animation # steps: DDIM sampling steps (1-60, default: 50) # cfg_scale: Classifier-free guidance scale (default: 12.0) # eta: DDIM eta (default: 1.0) # fps: FPS conditioning (default: 16) video_path = i2v.get_image( image=image_array, prompt='horses are walking on the grassland', steps=50, cfg_scale=12.0, eta=1.0, fps=16 ) print(f'Generated video: {video_path}') # Output: ./results/horses_are_walking_on_the.mp4 ``` -------------------------------- ### VideoCrafter Inference Configuration Source: https://context7.com/ailab-cvc/videocrafter/llms.txt YAML configuration for text-to-video inference. Specifies model architecture, diffusion parameters, and conditioning settings for a 512x512 latent diffusion model. ```yaml model: target: lvdm.models.ddpm3d.LatentDiffusion params: linear_start: 0.00085 linear_end: 0.012 num_timesteps_cond: 1 timesteps: 1000 first_stage_key: video cond_stage_key: caption cond_stage_trainable: false conditioning_key: crossattn image_size: [40, 64] # Latent resolution channels: 4 # Latent channels scale_factor: 0.18215 use_ema: false uncond_type: empty_seq # CFG uncondition type use_scale: true scale_b: 0.7 unet_config: target: lvdm.modules.networks.openaimodel3d.UNetModel params: in_channels: 4 out_channels: 4 model_channels: 320 attention_resolutions: [4, 2, 1] num_res_blocks: 2 channel_mult: [1, 2, 4, 4] num_head_channels: 64 transformer_depth: 1 context_dim: 1024 # CLIP embedding dimension temporal_conv: true temporal_attention: true temporal_length: 16 # Video frames addition_attention: true fps_cond: true # FPS conditioning enabled first_stage_config: target: lvdm.models.autoencoder.AutoencoderKL params: embed_dim: 4 ddconfig: resolution: 512 in_channels: 3 out_ch: 3 ch: 128 ch_mult: [1, 2, 4, 4] num_res_blocks: 2 cond_stage_config: target: lvdm.modules.encoders.condition.FrozenOpenCLIPEmbedder params: freeze: true layer: penultimate ``` -------------------------------- ### Batch DDIM Sampling for Video Generation Source: https://context7.com/ailab-cvc/videocrafter/llms.txt Python function to generate video batches using DDIM sampling with classifier-free guidance. Requires a loaded LatentDiffusion model and text prompts. Supports custom height, width, sampling steps, guidance scale, eta, and FPS. ```python from scripts.evaluation.funcs import batch_ddim_sampling, save_videos import torch def generate_videos(model, prompts, height=320, width=512, ddim_steps=50, cfg_scale=12.0, eta=1.0, fps=16): """ Generate videos from text prompts using batch DDIM sampling. Args: model: Loaded LatentDiffusion model prompts: List of text prompts height: Video height in pixels (must be divisible by 16) width: Video width in pixels (must be divisible by 16) ddim_steps: Number of DDIM sampling steps cfg_scale: Classifier-free guidance scale eta: DDIM eta (0=deterministic, 1=stochastic) fps: FPS conditioning value Returns: Tensor of shape [batch, samples, channels, time, height, width] """ batch_size = len(prompts) channels = model.channels frames = model.temporal_length h, w = height // 8, width // 8 # Latent dimensions noise_shape = [batch_size, channels, frames, h, w] fps_tensor = torch.tensor([fps] * batch_size).to(model.device).long() # Encode text prompts text_emb = model.get_learned_conditioning(prompts) cond = {"c_crossattn": [text_emb], "fps": fps_tensor} # Generate videos batch_samples = batch_ddim_sampling( model=model, cond=cond, noise_shape=noise_shape, n_samples=1, ddim_steps=ddim_steps, ddim_eta=eta, cfg_scale=cfg_scale ) return batch_samples # Usage example (assuming model is loaded): # prompts = ["A cat playing piano", "Sunset over ocean waves"] # videos = generate_videos(model, prompts, ddim_steps=50) # save_videos(videos, './output/', ['cat_piano', 'sunset'], fps=8) ``` -------------------------------- ### Text2Video Python API Source: https://context7.com/ailab-cvc/videocrafter/llms.txt Programmatically generate videos from text prompts using the Text2Video class. The class automatically handles model downloading from Hugging Face. ```python from scripts.gradio.t2v_test import Text2Video t2v = Text2Video(result_dir='./results/') video_path = t2v.get_prompt( prompt='A black swan swims gracefully on a calm pond', steps=50, cfg_scale=12.0, eta=1.0, fps=16 ) print(f'Generated video saved to: {video_path}') prompts = [ 'An elephant walking under the sea, 4K, high definition', 'A monkey playing a piano in a concert hall', 'Robot dancing in Times Square at night' ] for prompt in prompts: video_path = t2v.get_prompt(prompt, steps=25, cfg_scale=12.0) print(f'Created: {video_path}') ``` -------------------------------- ### Text2Video Python API Source: https://context7.com/ailab-cvc/videocrafter/llms.txt Programmatically generate videos from text prompts using the Text2Video class. This API handles automatic model downloading. ```APIDOC ## POST /api/videocrafter/python/t2v ### Description Use the Text2Video class for programmatic video generation with automatic model downloading. ### Method POST ### Endpoint /api/videocrafter/python/t2v ### Parameters #### Request Body - **prompt** (string) - Required - Text description of the desired video. - **steps** (integer) - Optional - DDIM sampling steps (1-60, default: 50). - **cfg_scale** (float) - Optional - Classifier-free guidance scale (1.0-30.0, default: 12.0). - **eta** (float) - Optional - DDIM eta for stochasticity (0.0-1.0, default: 1.0). - **fps** (integer) - Optional - Frames per second conditioning (4-32, default: 16). - **result_dir** (string) - Optional - Directory to save generated videos (default: './results/'). ### Request Example ```python from scripts.gradio.t2v_test import Text2Video t2v = Text2Video(result_dir='./results/') video_path = t2v.get_prompt( prompt='A black swan swims gracefully on a calm pond', steps=50, cfg_scale=12.0, eta=1.0, fps=16 ) print(f'Generated video saved to: {video_path}') ``` ### Response #### Success Response (200) - **video_path** (string) - The file path to the generated video. #### Response Example ```json { "video_path": "./results/A_black_swan_swims_gracef.mp4" } ``` ``` -------------------------------- ### VideoCrafter2 Citation Source: https://github.com/ailab-cvc/videocrafter/blob/main/README.md Use this BibTeX entry to cite the VideoCrafter2 technical report. ```bibtex @misc{chen2024videocrafter2, title={VideoCrafter2: Overcoming Data Limitations for High-Quality Video Diffusion Models}, author={Haoxin Chen and Yong Zhang and Xiaodong Cun and Menghan Xia and Xintao Wang and Chao Weng and Ying Shan}, year={2024}, eprint={2401.09047}, archivePrefix={arXiv}, primaryClass={cs.CV} } ``` -------------------------------- ### VideoCrafter1 Citation Source: https://github.com/ailab-cvc/videocrafter/blob/main/README.md Use this BibTeX entry to cite the VideoCrafter1 technical report. ```bibtex @misc{chen2023videocrafter1, title={VideoCrafter1: Open Diffusion Models for High-Quality Video Generation}, author={Haoxin Chen and Menghan Xia and Yingqing He and Yong Zhang and Xiaodong Cun and Shaoshu Yang and Jinbo Xing and Yaofang Liu and Qifeng Chen and Xintao Wang and Chao Weng and Ying Shan}, year={2023}, eprint={2310.19512}, archivePrefix={arXiv}, primaryClass={cs.CV} } ``` -------------------------------- ### Save Generated Videos to MP4 Source: https://context7.com/ailab-cvc/videocrafter/llms.txt Saves a batch of video tensors as MP4 files. Ensure input tensors are in the range [-1, 1]. The output format is H.264 encoded MP4. ```python from scripts.evaluation.funcs import save_videos import torch import torchvision def save_generated_videos(batch_tensors, output_dir, filenames, fps=10): """ Save batch of video tensors as MP4 files. Args: batch_tensors: Tensor of shape [batch, samples, channels, time, height, width] Values should be in range [-1, 1] output_dir: Directory to save videos filenames: List of output filenames (without extension) fps: Output video frame rate Output format: H.264 encoded MP4 """ import os os.makedirs(output_dir, exist_ok=True) n_samples = batch_tensors.shape[1] for idx, vid_tensor in enumerate(batch_tensors): video = vid_tensor.detach().cpu() video = torch.clamp(video.float(), -1., 1.) video = video.permute(2, 0, 1, 3, 4) # t,n,c,h,w # Create frame grid if multiple samples frame_grids = [ torchvision.utils.make_grid(framesheet, nrow=int(n_samples)) for framesheet in video ] grid = torch.stack(frame_grids, dim=0) # Convert from [-1,1] to [0,255] grid = (grid + 1.0) / 2.0 grid = (grid * 255).to(torch.uint8).permute(0, 2, 3, 1) savepath = os.path.join(output_dir, f"{filenames[idx]}.mp4") torchvision.io.write_video( savepath, grid, fps=fps, video_codec='h264', options={'crf': '10'} ) print(f'Saved: {savepath}') # Example usage: # save_generated_videos(batch_videos, './results/', ['video1', 'video2'], fps=8) ``` -------------------------------- ### Image2Video Python API Source: https://context7.com/ailab-cvc/videocrafter/llms.txt Convert static images to animated videos using the Image2Video class. This class also supports automatic model downloading from Hugging Face. ```python from scripts.gradio.i2v_test import Image2Video import numpy as np from PIL import Image i2v = Image2Video(result_dir='./results/') image = Image.open('prompts/i2v_prompts/horse.png').convert('RGB') image = image.resize((512, 320)) image_array = np.array(image) ``` -------------------------------- ### Latent Video Diffusion Models Citation Source: https://github.com/ailab-cvc/videocrafter/blob/main/README.md Use this BibTeX entry to cite the Latent Video Diffusion Models paper. ```bibtex @article{he2022lvdm, title={Latent Video Diffusion Models for High-Fidelity Long Video Generation}, author={Yingqing He and Tianyu Yang and Yong Zhang and Ying Shan and Qifeng Chen}, year={2022}, eprint={2211.13221}, archivePrefix={arXiv}, primaryClass={cs.CV} } ``` -------------------------------- ### Image2Video Python API Source: https://context7.com/ailab-cvc/videocrafter/llms.txt Convert static images to animated videos using the Image2Video class. This API also handles automatic model downloading. ```APIDOC ## POST /api/videocrafter/python/i2v ### Description Convert static images to animated videos using the Image2Video class with automatic model downloading. ### Method POST ### Endpoint /api/videocrafter/python/i2v ### Parameters #### Request Body - **image** (base64 encoded string or file path) - Required - The input image to animate. - **prompt** (string) - Required - Text prompt describing the desired video motion or content. - **steps** (integer) - Optional - DDIM sampling steps (1-60, default: 50). - **cfg_scale** (float) - Optional - Classifier-free guidance scale (1.0-30.0, default: 12.0). - **eta** (float) - Optional - DDIM eta for stochasticity (0.0-1.0, default: 1.0). - **fps** (integer) - Optional - Frames per second for the generated video (default: 8). - **result_dir** (string) - Optional - Directory to save generated videos (default: './results/'). ### Request Example ```python from scripts.gradio.i2v_test import Image2Video import numpy as np from PIL import Image i2v = Image2Video(result_dir='./results/') image = Image.open('prompts/i2v_prompts/horse.png').convert('RGB') image = image.resize((512, 320)) image_array = np.array(image) video_path = i2v.get_prompt( image=image_array, # or image_path='prompts/i2v_prompts/horse.png' prompt='a horse running on a field', steps=50, cfg_scale=12.0, eta=1.0, fps=8 ) print(f'Generated video saved to: {video_path}') ``` ### Response #### Success Response (200) - **video_path** (string) - The file path to the generated video. #### Response Example ```json { "video_path": "./results/horse_running_on_a_field.mp4" } ``` ``` -------------------------------- ### DynamiCrafter Citation Source: https://github.com/ailab-cvc/videocrafter/blob/main/README.md Use this BibTeX entry to cite the DynamiCrafter paper. ```bibtex @article{xing2023dynamicrafter, title={DynamiCrafter: Animating Open-domain Images with Video Diffusion Priors}, author={Jinbo Xing and Menghan Xia and Yong Zhang and Haoxin Chen and Xintao Wang and Tien-Tsin Wong and Ying Shan}, year={2023}, eprint={2310.12190}, archivePrefix={arXiv}, primaryClass={cs.CV} } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.