Open-Sora: Democratizing Efficient Video Production for All
Python
update config
zhengzangw9e0b314dab5d
diff --git a/README.md b/README.mdindex ddd7795..1bc4f14 100644--- a/README.md+++ b/README.md@@ -103,7 +103,7 @@ More samples are available in our [gallery](https://hpcaitech.github.io/Open-Sor<details><summary>View more</summary>-* [ ] Evaluation pipeline.+* [x] Evaluation pipeline.* [x] Complete the data processing pipeline (including dense optical flow, aesthetics scores, text-image similarity, etc.).* [x] Support image and video conditioning.* [x] Support variable aspect ratios, resolutions, durations.@@ -123,7 +123,7 @@ More samples are available in our [gallery](https://hpcaitech.github.io/Open-SorOther useful documents and links are listed below.-* Report: [report 1.0](docs/report_01.md), [report 1.1](docs/report_02.md), [acceleration.md](docs/acceleration.md)+* Report: [report 1.1](docs/report_02.md), [report 1.0](docs/report_01.md), [acceleration.md](docs/acceleration.md)* Repo structure: [structure.md](docs/structure.md)* Config file explanation: [config.md](docs/config.md)* Useful commands: [commands.md](docs/commands.md)diff --git a/docs/report_02.md b/docs/report_02.mdindex b225bf6..52f59df 100644--- a/docs/report_02.md+++ b/docs/report_02.md@@ -64,7 +64,7 @@ Typically, we unmask the frames to be conditioned on for image/video-to-video coInspired by [UL2](https://arxiv.org/abs/2205.05131), we introduce random mask strategy during training. Specifically, we randomly unmask the frames during training, including unmask the first frame, the first k frames, the last frame, the last k frames, the first and last k frames, random frames, etc. Based on Open-Sora 1.0, with 50% probability of applying masking, we see the model can learn to handle image conditioning (while 30% yields worse ability) for 10k steps, with a little text-to-video performance drop. Thus, for Open-Sora 1.1, we pretrain the model from scratch with masking strategy.-An illustration of masking strategy config to use in inference is given as follow. A five number tuple provides great flexibility in defining the mask strategy.+An illustration of masking strategy config to use in inference is given as follow. A five number tuple provides great flexibility in defining the mask strategy. By conditioning on generated frames, we can autogressively generate infinite frames (although error propagates).@@ -72,19 +72,22 @@ A detailed explanation of the mask strategy usage is available in [docs/config.m## Data Collection & Pipeline-As we found in Open-Sora 1.0, the data number and quality are crucial for training a good model, we work hard on scaling the dataset. First, we create an automatic pipeline following [SVD](https://arxiv.org/abs/2311.15127), inlcuding scene cutting, captioning, various scoring and filtering, and dataset management scripts and conventions.+As we found in Open-Sora 1.0, the data number and quality are crucial for training a good model, we work hard on scaling the dataset. First, we create an automatic pipeline following [SVD](https://arxiv.org/abs/2311.15127), inlcuding scene cutting, captioning, various scoring and filtering, and dataset management scripts and conventions. More infomation can be found in [docs/data_processing.md](/docs/data_processing.md).-We plan to use [panda-70M](https://snap-research.github.io/Panda-70M/) and other data to traing the model, which is approximately 30M+ data. However, we find disk IO a botteleneck for training and data processing at the same time. Thus, we can only prepare a 10M dataset and did not go through all processing pipeline that we built. Finally, we use a dataset with 9.7M videos + 2.6M images for pre-training, and 560k videos + 1.6M images for fine-tuning. The pretraining dataset statistics are shown below.+We plan to use [panda-70M](https://snap-research.github.io/Panda-70M/) and other data to traing the model, which is approximately 30M+ data. However, we find disk IO a botteleneck for training and data processing at the same time. Thus, we can only prepare a 10M dataset and did not go through all processing pipeline that we built. Finally, we use a dataset with 9.7M videos + 2.6M images for pre-training, and 560k videos + 1.6M images for fine-tuning. The pretraining dataset statistics are shown below. More information about the dataset can be found in [docs/datasets.md](/docs/datasets.md).Image text tokens (by T5 tokenizer):+Video text tokens (by T5 tokenizer). We directly use panda's short caption for training, and caption other datasets by ourselves. The generated caption is usually less than 200 tokens.+Video duration:+## Training Details@@ -92,11 +95,13 @@ Video duration:With limited computational resources, we have to carefully monitor the training process, and change the training strategy if we speculate the model is not learning well since there is no computation for ablation study. Thus, Open-Sora 1.1's training includes multiple changes, and as a result, ema is not applied.1. First, we fine-tune **6k** steps with images of different resolution from `Pixart-alpha-1024` checkpoints. We find the model easily adapts to generate images with different resolutions. We use [SpeeDiT](https://github.com/1zeryu/SpeeDiT) (iddpm-speed) to accelerate the diffusion training.-2. **[Stage 1]** Then, we pretrain the model with gradient-checkpointing for **24k** steps, which takes **4 days** on 64 H800 GPUs. Although the number of samples seen by the model is the same, we find the model learns slowly compared to a smaller batch size. We speculate that at an early stage, the number of steps is more important for training. The most videos are in **240p** resolution, and the config is similar to [stage2.py](/configs/opensora-v1-1/train/stage2.py).+2. **[Stage 1]** Then, we pretrain the model with gradient-checkpointing for **24k** steps, which takes **4 days** on 64 H800 GPUs. Although the number of samples seen by the model is the same, we find the model learns slowly compared to a smaller batch size. We speculate that at an early stage, the number of steps is more important for training. The most videos are in **240p** resolution, and the config is similar to [stage2.py](/configs/opensora-v1-1/train/stage2.py). The video looking is good, but the model does not know much about the temporal knowledge. We use mask ratio of 10%.3. **[Stage 1]** To increase the number of steps, we switch to a smaller batch size without gradient-checkpointing. We also add fps conditioning at this point. We trained **40k** steps for **2 days**. The most videos are in **144p** resolution, and the config file is [stage1.py](/configs/opensora-v1-1/train/stage1.py). We use a lower resolution as we find in Open-Sora 1.0 that the model can learn temporal knowledge with relatively low resolution.-4. **[Stage 1]** We find the model cannot learn well for long videos, and find a noised generation result as speculated to be half-precision problem found in Open-Sora 1.0 training. Thus, we adopt the QK-normalization to stabilize the training. We also switch iddpm-speed to iddpm. We trained for **17k** steps for **14 hours**. The most videos are in **144p** resolution, and the config file is [stage1.py](/configs/opensora-v1-1/train/stage1.py). The stage 1 training lasts for approximately one week, with total step **81k**.+4. **[Stage 1]** We find the model cannot learn well for long videos, and find a noised generation result as speculated to be half-precision problem found in Open-Sora 1.0 training. Thus, we adopt the QK-normalization to stabilize the training. Similar to SD3, we find the model quickly adapt to the QK-normalization. We also switch iddpm-speed to iddpm, and increase the mask ratio to 25% as we find image-condition not learning well. We trained for **17k** steps for **14 hours**. The most videos are in **144p** resolution, and the config file is [stage1.py](/configs/opensora-v1-1/train/stage1.py). The stage 1 training lasts for approximately one week, with total step **81k**.5. **[Stage 2]** We switch to a higher resolution, where most videos are in **240p and 480p** resolution ([stage2.py](/configs/opensora-v1-1/train/stage2.py)). We trained **22k** steps for **one day** on all pre-training data.-6. **[Stage 3]** We switch to a higher resolution, where most videos are in **480p and 720p** resolution ([stage3.py](/configs/opensora-v1-1/train/stage3.py)). We trained **4k** with **one day** on high-quality data.+6. **[Stage 3]** We switch to a higher resolution, where most videos are in **480p and 720p** resolution ([stage3.py](/configs/opensora-v1-1/train/stage3.py)). We trained **4k** with **one day** on high-quality data. We find loading previous stage's optimizer state can help the model learn faster.++To summarize, the training of Open-Sora 1.1 requires approximately **9 days** on 64 H800 GPUs.## Results and Evaluation@@ -104,6 +109,7 @@ With limited computational resources, we have to carefully monitor the trainingAs we get one step closer to the replication of Sora, we find many limitations for the current model, and these limitations point to the future work.+- **Generation Failure**: we fine many cases (especially when the total token number is large or the content is complex), our model fails to generate the scene.- **Noisy generation and influency**: we find the generated model is sometimes noisy and not fluent, especially for long videos. We think the problem is due to not using a temporal VAE. As [Pixart-Sigma](https://arxiv.org/abs/2403.04692) finds that adapting to a new VAE is simple, we plan to develop a temporal VAE for the model in the next version.- **Lack of time consistency**: we find the model cannot generate videos with high time consistency. We think the problem is due to the lack of training FLOPs. We plan to collect more data and continue training the model to improve the time consistency.- **Bad human generation**: We find the model cannot generate high-quality human videos. We think the problem is due to the lack of human data. We plan to collect more human data and continue training the model to improve the human generation.diff --git a/eval/README.md b/eval/README.mdindex e444f65..3ec8c7e 100644--- a/eval/README.md+++ b/eval/README.md@@ -5,12 +5,10 @@To conduct human evaluation, we need to generate various samples. We provide many prompts in `assets/texts`, and defined some test setting covering different resolution, duration and aspect ratio in `eval/sample.sh`. To facilitate the usage of multiple GPUs, we split sampling tasks into several parts.```bash-# image+# image (1)bash eval/sample.sh /path/to/ckpt -1-# video (2a to 2f)+# video (2a 2b 2c ...)bash eval/sample.sh /path/to/ckpt -2a-# video edit-bash eval/sample.sh /path/to/ckpt -3# launch 8 jobs at once (you must read the script to understand the details)bash eval/launch.sh /path/to/ckpt```@@ -20,13 +18,17 @@ bash eval/launch.sh /path/to/ckpt[VBench](https://github.com/Vchitect/VBench) is a benchmark for short text to video generation. We provide a script for easily generating samples required by VBench.```bash-# 4a to 4h-bash eval/vbench.sh /path/to/ckpt -4a+# vbench tasks (4a 4b 4c ...)+bash eval/sample.sh /path/to/ckpt -4a# launch 8 jobs at once (you must read the script to understand the details)bash eval/launch.sh /path/to/ckpt```-After generation, install the VBench package according to their [instructions](https://github.com/Vchitect/VBench?tab=readme-ov-file#hammer-installation). Then, run `bash eval/vbench/vbench.sh` to evaluate the generated samples.+After generation, install the VBench package according to their [instructions](https://github.com/Vchitect/VBench?tab=readme-ov-file#hammer-installation). Then, run the following commands to evaluate the generated samples.++```bash+bash eval/vbench/vbench.sh /path/to/video_folder+```## VBench-i2vdiff --git a/eval/launch.sh b/eval/launch.shindex 305ea76..ea7a5f4 100644--- a/eval/launch.sh+++ b/eval/launch.sh@@ -15,13 +15,15 @@ echo "Logging to $LOG_BASE"# == sample & human evaluation ==CUDA_VISIBLE_DEVICES=0 bash eval/sample.sh $CKPT -1 >${LOG_BASE}_1.log 2>&1 &-CUDA_VISIBLE_DEVICES=1 bash eval/sample.sh $CKPT -3 >${LOG_BASE}_3.log 2>&1 &-CUDA_VISIBLE_DEVICES=2 bash eval/sample.sh $CKPT -2a >${LOG_BASE}_2a.log 2>&1 &-CUDA_VISIBLE_DEVICES=3 bash eval/sample.sh $CKPT -2b >${LOG_BASE}_2b.log 2>&1 &-CUDA_VISIBLE_DEVICES=4 bash eval/sample.sh $CKPT -2c >${LOG_BASE}_2c.log 2>&1 &-CUDA_VISIBLE_DEVICES=5 bash eval/sample.sh $CKPT -2d >${LOG_BASE}_2d.log 2>&1 &-CUDA_VISIBLE_DEVICES=6 bash eval/sample.sh $CKPT -2e >${LOG_BASE}_2e.log 2>&1 &-CUDA_VISIBLE_DEVICES=7 bash eval/sample.sh $CKPT -2f >${LOG_BASE}_2f.log 2>&1 &+CUDA_VISIBLE_DEVICES=1 bash eval/sample.sh $CKPT -2a >${LOG_BASE}_2a.log 2>&1 &+CUDA_VISIBLE_DEVICES=2 bash eval/sample.sh $CKPT -2b >${LOG_BASE}_2b.log 2>&1 &+CUDA_VISIBLE_DEVICES=3 bash eval/sample.sh $CKPT -2c >${LOG_BASE}_2c.log 2>&1 &+CUDA_VISIBLE_DEVICES=4 bash eval/sample.sh $CKPT -2d >${LOG_BASE}_2d.log 2>&1 &+CUDA_VISIBLE_DEVICES=5 bash eval/sample.sh $CKPT -2e >${LOG_BASE}_2e.log 2>&1 &+CUDA_VISIBLE_DEVICES=6 bash eval/sample.sh $CKPT -2f >${LOG_BASE}_2f.log 2>&1 &+CUDA_VISIBLE_DEVICES=7 bash eval/sample.sh $CKPT -2g >${LOG_BASE}_2g.log 2>&1 &++# CUDA_VISIBLE_DEVICES=0 bash eval/sample.sh $CKPT -2h >${LOG_BASE}_2h.log 2>&1 &# == vbench ==# CUDA_VISIBLE_DEVICES=0 bash eval/sample.sh $CKPT -4a >${LOG_BASE}_4a.log 2>&1 &diff --git a/eval/multiple.sh b/eval/multiple.shnew file mode 100644index 0000000..4bbc784--- /dev/null+++ b/eval/multiple.sh@@ -0,0 +1,114 @@+#!/bin/bash++set -x+set -e++CKPT=$1+PROMPT=$2+NUM_SAMPLE=3+NAME=$(date +%Y%m%d%H%M%S)+CMD="python scripts/inference-long.py configs/opensora-v1-1/inference/sample.py"+if [[ $CKPT == *"ema"* ]]; then+ parentdir=$(dirname $CKPT)+ CKPT_BASE=$(basename $parentdir)_ema+else+ CKPT_BASE=$(basename $CKPT)+fi+OUTPUT="./samples_${CKPT_BASE}_${NAME}"+start=$(date +%s)++# Generate samples++# 16x240p++# 64x240p++# 128x240p++# 16x320p++# 64x320p++# 128x320p++# 16x480p+# 1:1+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 16x480p_1_1 \+ --num-frames 16 --image-size 360 360 --num-samples $NUM_SAMPLE+# 16:9+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 16x480p_16_9 \+ --num-frames 16 --image-size 360 640 --num-samples $NUM_SAMPLE+# 9:16+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 16x480p_9_16 \+ --num-frames 16 --image-size 1280 720 --num-samples $NUM_SAMPLE+# 4:3+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 16x480p_4_3 \+ --num-frames 16 --image-size 832 1108 --num-samples $NUM_SAMPLE+# 3:4+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 16x480p_3_4 \+ --num-frames 16 --image-size 1108 832 --num-samples $NUM_SAMPLE+# 1:2+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 16x480p_1_2 \+ --num-frames 16 --image-size 1358 600 --num-samples $NUM_SAMPLE+# 2:1+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 16x480p_2_1 \+ --num-frames 16 --image-size 600 1358++# 32x480p++# 64x480p+++# 16x720p+# 1:1+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 16x720p_1_1 \+ --num-frames 16 --image-size 960 960 --num-samples $NUM_SAMPLE+# 16:9+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 16x720p_16_9 \+ --num-frames 16 --image-size 720 1280 --num-samples $NUM_SAMPLE+# 9:16+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 16x720p_9_16 \+ --num-frames 16 --image-size 1280 720 --num-samples $NUM_SAMPLE+# 4:3+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 16x720p_4_3 \+ --num-frames 16 --image-size 832 1108 --num-samples $NUM_SAMPLE+# 3:4+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 16x720p_3_4 \+ --num-frames 16 --image-size 1108 832 --num-samples $NUM_SAMPLE+# 1:2+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 16x720p_1_2 \+ --num-frames 16 --image-size 1358 600 --num-samples $NUM_SAMPLE+# 2:1+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 16x720p_2_1 \+ --num-frames 16 --image-size 600 1358++# 32x720p+# 1:1+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 32x720p_1_1 \+ --num-frames 32 --image-size 960 960 --num-samples $NUM_SAMPLE+# 16:9+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 32x720p_16_9 \+ --num-frames 32 --image-size 720 1280 --num-samples $NUM_SAMPLE+# 9:16+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 32x720p_9_16 \+ --num-frames 32 --image-size 1280 720 --num-samples $NUM_SAMPLE+# 4:3+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 32x720p_4_3 \+ --num-frames 32 --image-size 832 1108 --num-samples $NUM_SAMPLE+# 3:4+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 32x720p_3_4 \+ --num-frames 32 --image-size 1108 832 --num-samples $NUM_SAMPLE+# 1:2+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 32x720p_1_2 \+ --num-frames 32 --image-size 1358 600 --num-samples $NUM_SAMPLE+# 2:1+eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --sample-name 32x720p_2_1 \+ --num-frames 32 --image-size 600 1358++### End++end=$(date +%s)++runtime=$((end - start))++echo "Runtime: $runtime seconds"diff --git a/eval/sample.sh b/eval/sample.shindex 7be563f..303723c 100644--- a/eval/sample.sh+++ b/eval/sample.sh@@ -15,22 +15,22 @@ elsefiOUTPUT="./samples/samples_${CKPT_BASE}"start=$(date +%s)-DEFAULT_BS=4+DEFAULT_BS=8### Functionsfunction run_image() { # 10min# 1.1 1024x1024- eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2i_samples.txt --save-dir $OUTPUT --num-frames 1 --image-size 1024 1024 --sample-name 1024x1024+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2i_samples.txt --save-dir $OUTPUT --num-frames 1 --image-size 1024 1024 --sample-name 1024x1024 --batch-size $DEFAULT_BS# 1.2 240x426- eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2i_samples.txt --save-dir $OUTPUT --num-frames 1 --image-size 240 426 --sample-name 240x426 --end-index 3+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2i_samples.txt --save-dir $OUTPUT --num-frames 1 --image-size 240 426 --sample-name 240x426 --end-index 3 --batch-size $DEFAULT_BS# 1.3 512x512- eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2i_samples.txt --save-dir $OUTPUT --num-frames 1 --image-size 512 512 --sample-name 512x512 --end-index 3- eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_samples.txt --save-dir $OUTPUT --num-frames 1 --image-size 512 512 --sample-name 512x512 --end-index 3- eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 1 --image-size 512 512 --sample-name 512x512 --end-index 3- eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames 1 --image-size 512 512 --sample-name 512x512 --end-index 3+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2i_samples.txt --save-dir $OUTPUT --num-frames 1 --image-size 512 512 --sample-name 512x512 --end-index 3 --batch-size $DEFAULT_BS+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_samples.txt --save-dir $OUTPUT --num-frames 1 --image-size 512 512 --sample-name 512x512 --end-index 3 --batch-size $DEFAULT_BS+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 1 --image-size 512 512 --sample-name 512x512 --end-index 3 --batch-size $DEFAULT_BS+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames 1 --image-size 512 512 --sample-name 512x512 --end-index 3 --batch-size $DEFAULT_BS# 1.4 720p multi-resolution# 1:1@@ -56,26 +56,9 @@ function run_video_a() { # 30min, sample & multi-resolutioneval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_samples.txt --save-dir $OUTPUT --num-frames 16 --image-size 240 426 --sample-name sample_16x240x426 --batch-size $DEFAULT_BSeval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_samples.txt --save-dir $OUTPUT --num-frames 32 --image-size 240 426 --sample-name sample_32x240x426 --batch-size $DEFAULT_BSeval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_samples.txt --save-dir $OUTPUT --num-frames 64 --image-size 240 426 --sample-name sample_64x240x426 --batch-size $DEFAULT_BS- eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_samples.txt --save-dir $OUTPUT --num-frames 16 --image-size 480 854 --sample-name sample_16x480x854- eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_samples.txt --save-dir $OUTPUT --num-frames 32 --image-size 480 854 --sample-name sample_32x480x854- eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_samples.txt --save-dir $OUTPUT --num-frames 16 --image-size 720 1280 --sample-name sample_16x720x1280-- # 16x720p multi-resolution- # 1:1- PROMPT="A soaring drone footage captures the majestic beauty of a coastal cliff, its red and yellow stratified rock faces rich in color and against the vibrant turquoise of the sea. Seabirds can be seen taking flight around the cliff's precipices. As the drone slowly moves from different angles, the changing sunlight casts shifting shadows that highlight the rugged textures of the cliff and the surrounding calm sea. The water gently laps at the rock base and the greenery that clings to the top of the cliff, and the scene gives a sense of peaceful isolation at the fringes of the ocean. The video captures the essence of pristine natural beauty untouched by human structures."- eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 16 --image-size 960 960 --sample-name 720p_1_1- # 16:9- eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 16 --image-size 720 1280 --sample-name 720p_16_9- # 9:16- eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 16 --image-size 1280 720 --sample-name 720p_9_16- # 4:3- eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 16 --image-size 832 1108 --sample-name 720p_4_3- # 3:4- eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 16 --image-size 1108 832 --sample-name 720p_3_4- # 1:2- eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 16 --image-size 1358 600 --sample-name 720p_1_2- # 2:1- eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 16 --image-size 600 1358 --sample-name 720p_2_1+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_samples.txt --save-dir $OUTPUT --num-frames 16 --image-size 480 854 --sample-name sample_16x480x854 --batch-size $DEFAULT_BS+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_samples.txt --save-dir $OUTPUT --num-frames 32 --image-size 480 854 --sample-name sample_32x480x854 --batch-size $DEFAULT_BS+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_samples.txt --save-dir $OUTPUT --num-frames 16 --image-size 720 1280 --sample-name sample_16x720x1280 --batch-size $DEFAULT_BS}function run_video_b() { # 30min, short 16x240p & 64x240p@@ -83,47 +66,69 @@ function run_video_b() { # 30min, short 16x240p & 64x240peval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 32 --image-size 240 426 --sample-name short_32x240x426 --batch-size $DEFAULT_BS# 64x240p, short- eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 64 --image-size 240 426 --sample-name short_64x240x426+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 64 --image-size 240 426 --sample-name short_64x240x426 --batch-size $DEFAULT_BS}function run_video_c() { # 30min, sora 16x240p & short 128x240p+ # 16x240p, sora+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames 16 --image-size 426 240 --sample-name sora_16x426x240 --batch-size $DEFAULT_BS+# 16x240p, soraeval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames 16 --image-size 240 426 --sample-name sora_16x240x426 --batch-size $DEFAULT_BS# 128x240p, sora- eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames 128 --image-size 240 426 --sample-name sora_128x240x426+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames 128 --image-size 240 426 --sample-name sora_128x240x426 --batch-size $DEFAULT_BS}function run_video_d() { # 30min, sora 32x480p# 32x480p, short- eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 32 --image-size 480 854 --sample-name short_32x480x854+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 32 --image-size 480 854 --sample-name short_32x480x854 --batch-size $DEFAULT_BS}function run_video_e() { # 30min# 64x480p, sora- eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames 64 --image-size 480 854 --sample-name sora_64x480x854+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames 64 --image-size 480 854 --sample-name sora_64x480x854 --batch-size 4}function run_video_f() { # 30min# 16x720p, sora- eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames 16 --image-size 720 1280 --sample-name sora_16x720x1280+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames 16 --image-size 720 1280 --sample-name sora_16x720x1280 --batch-size $DEFAULT_BS+}++function run_video_g() {+ # 16x720p multi-resolution+ # 1:1+ PROMPT="A soaring drone footage captures the majestic beauty of a coastal cliff, its red and yellow stratified rock faces rich in color and against the vibrant turquoise of the sea. Seabirds can be seen taking flight around the cliff's precipices. As the drone slowly moves from different angles, the changing sunlight casts shifting shadows that highlight the rugged textures of the cliff and the surrounding calm sea. The water gently laps at the rock base and the greenery that clings to the top of the cliff, and the scene gives a sense of peaceful isolation at the fringes of the ocean. The video captures the essence of pristine natural beauty untouched by human structures."+ eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 16 --image-size 960 960 --sample-name 720p_1_1+ # 16:9+ eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 16 --image-size 720 1280 --sample-name 720p_16_9+ # 9:16+ eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 16 --image-size 1280 720 --sample-name 720p_9_16+ # 4:3+ eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 16 --image-size 832 1108 --sample-name 720p_4_3+ # 3:4+ eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 16 --image-size 1108 832 --sample-name 720p_3_4+ # 1:2+ eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 16 --image-size 1358 600 --sample-name 720p_1_2+ # 2:1+ eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 16 --image-size 600 1358 --sample-name 720p_2_1}-function run_video_edit() { # 23min+function run_video_h() { # 23min# 3.1 image-conditioned long video generationeval $CMD_REF --ckpt-path $CKPT --save-dir $OUTPUT --sample-name ref_L10C4_16x240x426 \--prompt-path assets/texts/t2v_ref.txt --start-index 0 --end-index 3 \--num-frames 16 --image-size 240 426 \--loop 5 --condition-frame-length 4 \--reference-path assets/images/condition/cliff.png assets/images/condition/wave.png assets/images/condition/ship.png \- --mask-strategy "0" "0" "0"+ --mask-strategy "0" "0" "0" --batch-size $DEFAULT_BSeval $CMD_REF --ckpt-path $CKPT --save-dir $OUTPUT --sample-name ref_L10C4_64x240x426 \--prompt-path assets/texts/t2v_ref.txt --start-index 0 --end-index 3 \--num-frames 64 --image-size 240 426 \--loop 5 --condition-frame-length 16 \--reference-path assets/images/condition/cliff.png assets/images/condition/wave.png assets/images/condition/ship.png \- --mask-strategy "0" "0" "0"+ --mask-strategy "0" "0" "0" --batch-size $DEFAULT_BS# 3.2eval $CMD_REF --ckpt-path $CKPT --save-dir $OUTPUT --sample-name ref_L1_128x240x426 \@@ -131,12 +136,12 @@ function run_video_edit() { # 23min--num-frames 128 --image-size 240 426 \--loop 1 \--reference-path assets/images/condition/cliff.png "assets/images/condition/cactus-sad.png\;assets/images/condition/cactus-happy.png" https://cdn.openai.com/tmp/s/interp/d0.mp4 \- --mask-strategy "0\;0,0,0,-1,1" "0\;0,1,0,-1,1" "0,0,0,0,64,0.5"+ --mask-strategy "0\;0,0,0,-1,1" "0\;0,1,0,-1,1" "0,0,0,0,64,0.5" --batch-size $DEFAULT_BS}# vbench has 950 samples-VBENCH_BS=4+VBENCH_BS=32 # 80GBVBENCH_FRAMES=16VBENCH_H=240VBENCH_W=426@@ -190,11 +195,15 @@ function run_vbenck_h() { # 2h# vbench-i2v has 1120 samples+VBENCH_I2V_FRAMES=16+VBENCH_I2V_H=256+VBENCH_I2V_W=256+function run_vbenck_i2v_a() {eval $CMD_REF --ckpt-path $CKPT --save-dir ${OUTPUT}_vbench_i2v --prompt-as-path --num-sample 5 \--prompt-path assets/texts/VBench/all_i2v.txt \--start-index 0 --end-index 140 \- --image-size 256 256+ --num-frames $VBENCH_I2V_FRAMES --image-size $VBENCH_I2V_H $VBENCH_I2V_W --batch-size $VBENCH_BS}function run_vbenck_i2v_b() {@@ -254,40 +263,37 @@ for arg in "$@"; doecho "Running image samples..."run_imagefi- # video: sample 16x240p & multi-resolutionif [[ "$arg" = -2a ]] || [[ "$arg" = --video ]]; thenecho "Running video samples a..."run_video_afi- # video: short 16x240p & 64x240pif [[ "$arg" = -2b ]] || [[ "$arg" = --video ]]; thenecho "Running video samples b..."run_video_bfi- # video: sora 16x240p & short 128x240pif [[ "$arg" = -2c ]] || [[ "$arg" = --video ]]; thenecho "Running video samples c..."run_video_cfi- # short 16x480pif [[ "$arg" = -2d ]] || [[ "$arg" = --video ]]; thenecho "Running video samples d..."run_video_dfi- # short 64x480pif [[ "$arg" = -2e ]] || [[ "$arg" = --video ]]; thenecho "Running video samples e..."run_video_efi- # short 16x720pif [[ "$arg" = -2f ]] || [[ "$arg" = --video ]]; thenecho "Running video samples f..."run_video_ffi- # video edit- if [[ "$arg" = -3 ]] || [[ "$arg" = --video-edit ]]; then- echo "Running video edit samples..."- run_video_edit+ if [[ "$arg" = -2g ]] || [[ "$arg" = --video ]]; then+ echo "Running video samples g..."+ run_video_g+ fi+ if [[ "$arg" = -2h ]] || [[ "$arg" = --video ]]; then+ echo "Running video samples h..."+ run_video_hfi# vbenchif [[ "$arg" = -4a ]] || [[ "$arg" = --vbench ]]; thendiff --git a/opensora/datasets/aspect.py b/opensora/datasets/aspect.pyindex a06b10c..57e33f2 100644--- a/opensora/datasets/aspect.py+++ b/opensora/datasets/aspect.py@@ -105,27 +105,6 @@ ASPECT_RATIO_720P = {# S = 409920ASPECT_RATIO_480P = {- "0.38": (294, 784),- "0.43": (314, 732),- "0.48": (332, 692),- "0.50": (340, 680),- "0.53": (350, 662),- "0.54": (352, 652),- "0.56": (360, 640), # base- "0.62": (380, 608),- "0.67": (392, 588),- "0.75": (416, 554),- "1.00": (480, 480),- "1.33": (554, 416),- "1.50": (588, 392),- "1.78": (640, 360),- "1.89": (660, 350),- "2.00": (678, 340),- "2.08": (692, 332),-}--# S = 230400-ASPECT_RATIO_360P = {"0.38": (392, 1046),"0.43": (420, 980),"0.48": (444, 925),@@ -145,6 +124,27 @@ ASPECT_RATIO_360P = {"2.08": (924, 444),}+# S = 230400+ASPECT_RATIO_360P = {+ "0.38": (294, 784),+ "0.43": (314, 732),+ "0.48": (332, 692),+ "0.50": (340, 680),+ "0.53": (350, 662),+ "0.54": (352, 652),+ "0.56": (360, 640), # base+ "0.62": (380, 608),+ "0.67": (392, 588),+ "0.75": (416, 554),+ "1.00": (480, 480),+ "1.33": (554, 416),+ "1.50": (588, 392),+ "1.78": (640, 360),+ "1.89": (660, 350),+ "2.00": (678, 340),+ "2.08": (692, 332),+}+# S = 102240ASPECT_RATIO_240P = {"0.38": (196, 522),diff --git a/scripts/inference-long.py b/scripts/inference-long.pyindex 5a73d4e..7f2f4d5 100644--- a/scripts/inference-long.py+++ b/scripts/inference-long.py@@ -233,6 +233,13 @@ def main():batch_prompts_raw, additional_infos = extract_json_from_prompts(batch_prompts_raw)batch_prompts_loops = process_prompts(batch_prompts_raw, cfg.loop)video_clips = []+ # handle the last batch+ if len(batch_prompts_raw) < cfg.batch_size and cfg.multi_resolution == "STDiT2":+ model_args["height"] = model_args["height"][: len(batch_prompts_raw)]+ model_args["width"] = model_args["width"][: len(batch_prompts_raw)]+ model_args["num_frames"] = model_args["num_frames"][: len(batch_prompts_raw)]+ model_args["ar"] = model_args["ar"][: len(batch_prompts_raw)]+ model_args["fps"] = model_args["fps"][: len(batch_prompts_raw)]# 4.2. load reference videos & imagesfor j, info in enumerate(additional_infos):diff --git a/scripts/inference.py b/scripts/inference.pyindex ccf1417..ff9f118 100644--- a/scripts/inference.py+++ b/scripts/inference.py@@ -115,6 +115,13 @@ def main():batch_prompts_raw = prompts[i : i + cfg.batch_size]batch_prompts = [text_preprocessing(prompt) for prompt in batch_prompts_raw]z = torch.randn(len(batch_prompts), vae.out_channels, *latent_size, device=device, dtype=dtype)+ # handle the last batch+ if len(batch_prompts_raw) < cfg.batch_size and cfg.multi_resolution == "STDiT2":+ model_args["height"] = model_args["height"][: len(batch_prompts_raw)]+ model_args["width"] = model_args["width"][: len(batch_prompts_raw)]+ model_args["num_frames"] = model_args["num_frames"][: len(batch_prompts_raw)]+ model_args["ar"] = model_args["ar"][: len(batch_prompts_raw)]+ model_args["fps"] = model_args["fps"][: len(batch_prompts_raw)]# 4.3. diffusion samplingold_sample_idx = sample_idx