Open-Sora: Democratizing Efficient Video Production for All
Python
format
Shen-Chenhui2401377f10fe
diff --git a/eval/human_eval/launch.sh b/eval/human_eval/launch.shindex 133eb05..10774c7 100644--- a/eval/human_eval/launch.sh+++ b/eval/human_eval/launch.sh@@ -18,11 +18,12 @@ mkdir -p ${LOG_BASE}echo "Logging to $LOG_BASE"GPUS=(0 1 2 3 4 5 6 7)-TASK_ID_LIST=(1 2a 2b 2c 2d 2e 2f 2g) # 2h not supported yet-FRAME_LIST=(1 $NUM_FRAMES $NUM_FRAMES $NUM_FRAMES $NUM_FRAMES $NUM_FRAMES $NUM_FRAMES $NUM_FRAMES)+# TASK_ID_LIST=(1 2a 2b 2c 2d 2e 2f 2g) # move image to video task+TASK_ID_LIST=(2a 2b 2c 2d 2e 2f 2g 2h)+# FRAME_LIST=(1 $NUM_FRAMES $NUM_FRAMES $NUM_FRAMES $NUM_FRAMES $NUM_FRAMES $NUM_FRAMES $NUM_FRAMES)for i in "${!GPUS[@]}"; do- CUDA_VISIBLE_DEVICES=${GPUS[i]} bash eval/sample.sh $CKPT ${FRAME_LIST[i]} $MODEL_NAME -${TASK_ID_LIST[i]} >${LOG_BASE}/${TASK_ID_LIST[i]}.log 2>&1 &+ CUDA_VISIBLE_DEVICES=${GPUS[i]} bash eval/sample.sh $CKPT $NUM_FRAMES $MODEL_NAME -${TASK_ID_LIST[i]} >${LOG_BASE}/${TASK_ID_LIST[i]}.log 2>&1 &done# kill all by: pkill -f "inference"diff --git a/eval/sample.sh b/eval/sample.shindex 59394b9..b5b6c0f 100644--- a/eval/sample.sh+++ b/eval/sample.sh@@ -38,7 +38,8 @@ DEFAULT_BS=1### Functions-function run_image() { # 10min+# called inside run_video_b+function run_image() { # 14min# # 1.1 1024x1024eval $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@@ -69,7 +70,7 @@ function run_image() { # 10mineval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 1 --image-size 600 1358 --sample-name 720p_2_1}-function run_video_a() { # 30min, sample & multi-resolution+function run_video_a() { # 42min, sample & multi-resolution# sampleeval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_samples.txt --save-dir $OUTPUT --num-frames $NUM_FRAMES --image-size 144 256 --sample-name sample_${NUM_FRAMES}x144x256 --batch-size $DEFAULT_BSeval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_samples.txt --save-dir $OUTPUT --num-frames $NUM_FRAMES --image-size 240 426 --sample-name sample_${NUM_FRAMES}x240x426 --batch-size $DEFAULT_BS@@ -80,7 +81,12 @@ function run_video_a() { # 30min, sample & multi-resolutioneval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_samples.txt --save-dir $OUTPUT --num-frames $NUM_FRAMES --image-size 720 1280 --sample-name sample_${NUM_FRAMES}x720x1280 --batch-size $DEFAULT_BS}-function run_video_b() { # 30min, short 16x240p & 64x240p+function run_video_b() { # 18min + 14min = 32min, short 16x240p & 64x240p+ # run image+ echo "Inside run_video_b, running image samples..."+ run_image++ echo "Inside run_video_b, running video samples..."# 32x240p, shorteval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames $DOUBLE_FRAMES --image-size 240 426 --sample-name short_${DOUBLE_FRAMES}x240x426 --batch-size $DEFAULT_BS@@ -88,7 +94,7 @@ function run_video_b() { # 30min, short 16x240p & 64x240peval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames $QUAD_FRAMES --image-size 240 426 --sample-name short_${QUAD_FRAMES}x240x426 --batch-size $DEFAULT_BS}-function run_video_c() { # 30min, sora 16x240p & short 128x240p+function run_video_c() { # 60min, sora 16x240p & short 128x240p# 16x240p, soraeval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames $NUM_FRAMES --image-size 426 240 --sample-name sora_${NUM_FRAMES}x426x240 --batch-size $DEFAULT_BS@@ -99,22 +105,25 @@ function run_video_c() { # 30min, sora 16x240p & short 128x240peval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames $OCT_FRAMES --image-size 240 426 --sample-name sora_${OCT_FRAMES}x240x426 --batch-size $DEFAULT_BS}-function run_video_d() { # 30min, sora 32x480p+function run_video_d() { # 21min + 30min = 51min, sora 32x480p# 32x480p, shorteval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames $DOUBLE_FRAMES --image-size 480 854 --sample-name short_${DOUBLE_FRAMES}x480x854 --batch-size $DEFAULT_BS++ # 64x480p, sora, moved from run_video_e+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames $QUAD_FRAMES --image-size 480 854 --sample-name sora_${QUAD_FRAMES}x480x854 --batch-size $DEFAULT_BS --start-index 0 --end-index 16}-function run_video_e() { # 30min+function run_video_e() { # 90min * 2/3 = 60min# 64x480p, sora- eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames $QUAD_FRAMES --image-size 480 854 --sample-name sora_${QUAD_FRAMES}x480x854 --batch-size $DEFAULT_BS+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames $QUAD_FRAMES --image-size 480 854 --sample-name sora_${QUAD_FRAMES}x480x854 --batch-size $DEFAULT_BS --start-index 16 --end-index 100}-function run_video_f() { # 30min+function run_video_f() { # 60min# 16x720p, soraeval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_sora.txt --save-dir $OUTPUT --num-frames $NUM_FRAMES --image-size 720 1280 --sample-name sora_${NUM_FRAMES}x720x1280 --batch-size $DEFAULT_BS}-function run_video_g() {+function run_video_g() { # 15min# 16x720p multi-resolution# 1:1PROMPT="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."@@ -133,29 +142,29 @@ function run_video_g() {eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames $NUM_FRAMES --image-size 600 1358 --sample-name 720p_2_1}-function run_video_h() { # 23min+function run_video_h() { # 61min# 3.1 image-conditioned long video generation- eval $CMD --ckpt-path $CKPT --save-dir $OUTPUT --sample-name ref_L10C4_16x240x426 \+ eval $CMD --ckpt-path $CKPT --save-dir $OUTPUT --sample-name ref_L10C4_${NUM_FRAMES}x240x426 \--prompt-path assets/texts/t2v_ref.txt --start-index 0 --end-index 3 \--num-frames $NUM_FRAMES --image-size 240 426 \- --loop 5 --condition-frame-length 4 \+ --loop 5 --condition-frame-length 15 \--reference-path assets/images/condition/cliff.png assets/images/condition/wave.png assets/images/condition/ship.png \--mask-strategy "0" "0" "0" --batch-size $DEFAULT_BS- eval $CMD --ckpt-path $CKPT --save-dir $OUTPUT --sample-name ref_L10C4_64x240x426 \+ eval $CMD --ckpt-path $CKPT --save-dir $OUTPUT --sample-name ref_L10C4_${QUAD_FRAMES}x240x426 \--prompt-path assets/texts/t2v_ref.txt --start-index 0 --end-index 3 \- --num-frames $NUM_FRAMES --image-size 240 426 \- --loop 5 --condition-frame-length 16 \+ --num-frames $QUAD_FRAMES --image-size 240 426 \+ --loop 5 --condition-frame-length 60 \--reference-path assets/images/condition/cliff.png assets/images/condition/wave.png assets/images/condition/ship.png \--mask-strategy "0" "0" "0" --batch-size $DEFAULT_BS# 3.2- eval $CMD --ckpt-path $CKPT --save-dir $OUTPUT --sample-name ref_L1_128x240x426 \+ eval $CMD --ckpt-path $CKPT --save-dir $OUTPUT --sample-name ref_L1_${OCT_FRAMES}x240x426 \--prompt-path assets/texts/t2v_ref.txt --start-index 3 --end-index 6 \- --num-frames $NUM_FRAMES --image-size 240 426 \+ --num-frames $OCT_FRAMES --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" --batch-size $DEFAULT_BS+ --mask-strategy "0\;0,0,0,-1,1" "0\;0,1,0,-1,1" "0,0,0,0,${QUAD_FRAMES},0.5" --batch-size $DEFAULT_BS}# vbench has 950 samplesdiff --git a/eval/vbench_i2v/calc_vbench_i2v.py b/eval/vbench_i2v/calc_vbench_i2v.pyindex 5692fac..d47a169 100644--- a/eval/vbench_i2v/calc_vbench_i2v.py+++ b/eval/vbench_i2v/calc_vbench_i2v.py@@ -1,5 +1,6 @@import argparseimport os+import timeimport torch@@ -23,6 +24,10 @@ def parse_args():parser = argparse.ArgumentParser()parser.add_argument("video_folder", type=str) # samples/samples..._vbench_i2v/parser.add_argument("model_ckpt", type=str)+ parser.add_argument("--start", type=int, default=0) # start index of dimension to be evaluated+ parser.add_argument("--end", type=int, default=-1) # start index of dimension to be evaluated+ parser.add_argument("--calc_i2v", type=bool, default=True)+ parser.add_argument("--calc_quality", type=bool, default=True)args = parser.parse_args()return args@@ -33,15 +38,25 @@ if __name__ == "__main__":os.makedirs(output_dir, exist_ok=True)video_path = args.video_folder- my_VBench_I2V = VBenchI2V(torch.device("cuda"), full_info_path, output_dir)- for i2v_dim in i2v_dimensions:- my_VBench_I2V.evaluate(videos_path=video_path, name=i2v_dim, dimension_list=[i2v_dim], resolution="1-1")+ start_time = time.time()++ if args.calc_i2v:+ my_VBench_I2V = VBenchI2V(torch.device("cuda"), full_info_path, output_dir)+ if args.end == -1: # adjust end accordingly+ args.end = len(i2v_dimensions)+ for i2v_dim in i2v_dimensions[args.start : args.end]:+ my_VBench_I2V.evaluate(videos_path=video_path, name=i2v_dim, dimension_list=[i2v_dim], resolution="1-1")kwargs = {}kwargs["imaging_quality_preprocessing_mode"] = "longer" # use VBench/evaluate.py default- my_VBench = VBench(torch.device("cuda"), full_info_path, output_dir)- for quality_dim in video_quality_dimensions:- my_VBench.evaluate(- videos_path=video_path, name=quality_dim, dimension_list=[quality_dim], mode="vbench_standard", **kwargs- )+ if args.calc_quality:+ if args.end == -1: # adjust end accordingly+ args.end = len(video_quality_dimensions)+ my_VBench = VBench(torch.device("cuda"), full_info_path, output_dir)+ for quality_dim in video_quality_dimensions[args.start : args.end]:+ my_VBench.evaluate(+ videos_path=video_path, name=quality_dim, dimension_list=[quality_dim], mode="vbench_standard", **kwargs+ )++ print("Runtime: %s seconds " % (time.time() - start_time))diff --git a/eval/vbench_i2v/launch_calc.sh b/eval/vbench_i2v/launch_calc.shnew file mode 100644index 0000000..322ae56--- /dev/null+++ b/eval/vbench_i2v/launch_calc.sh@@ -0,0 +1,22 @@+# !/bin/bash++set -x+set -e++VIDEO_DIR=$1+CKPT_DIR=$2+LOG_BASE=$CKPT_DIR+mkdir -p $LOG_BASE+echo "Logging to $LOG_BASE"++GPUS=(0 1 2 3 4 5 6 7)+CALC_I2V_LIST=(True True False False False False False False)+CALC_QUALITY_LIST=(False False True True True True True True)+START_INDEX_LIST=(0 2 0 2 3 4 5 6)+END_INDEX_LIST=(2 -1 2 3 4 5 6 -1)+TASK_ID_LIST=(calc_vbench_i2v_a calc_vbench_i2v_b calc_vbench_i2v_c calc_vbench_i2v_d calc_vbench_i2v_e calc_vbench_i2v_f calc_vbench_i2v_g calc_vbench_i2v_h) # for log records only+++for i in "${!GPUS[@]}"; do+ CUDA_VISIBLE_DEVICES=${GPUS[i]} python eval/vbench/calc_vbench_i2v.py $VIDEO_DIR $CKPT_DIR --calc_i2v ${CALC_I2V_LIST[i]} --calc_quality ${CALC_QUALITY_LIST[i]} --start ${START_INDEX_LIST[i]} --end ${END_INDEX_LIST[i]} > ${LOG_BASE}/${TASK_ID_LIST[i]}.log 2>&1 &+donediff --git a/parallel_eval.sh b/parallel_eval.shnew file mode 100644index 0000000..3f30bc2--- /dev/null+++ b/parallel_eval.sh@@ -0,0 +1,231 @@+#!/bin/bash++CKPT=$1+NUM_FRAMES=$2+MODEL_NAME=$3+LOG_BASE=$(dirname $CKPT)/eval+if [[ $CKPT == *"ema"* ]]; then+ parentdir=$(dirname $CKPT)+ CKPT_BASE=$(basename $parentdir)_ema+else+ CKPT_BASE=$(basename $CKPT)+fi+VBENCH_SAMPLE_DIR=samples/samples_${MODEL_NAME}_${CKPT_BASE}_vbench++sleep_time=10m++human_eval_ready=0+human_ready_count=7+loss_eval_ready=0+loss_ready_count=6+vbench_gen_ready=0+vbench_gen_ready_count=8+vbench_calc_ready=0+vbench_calc_ready_count=8+vbench_i2v_gen_ready=0+vbench_i2v_gen_ready_count=8+vbench_i2v_calc_ready=0+vbench_i2v_calc_ready_count=8++# check if human eval ready+function check_human_eval(){+ term='Runtime:'+ finished_list=()+ TASK_ID_LIST=(2a 2b 2c 2d 2e 2f 2g 2h)++ for i in "${!TASK_ID_LIST[@]}"; do+ last_line=$(tail -n 1 ${LOG_BASE}/${TASK_ID_LIST[i]}.log)+ if [[ $last_line == *${term}* ]];+ then+ finished_list+=(${TASK_ID_LIST[i]})++ fi+ done++ echo "completed tasks: ${finished_list[@]}"++ if [ ${#finished_list[@]}=$human_ready_count ];+ then+ human_eval_ready=1+ else+ echo ${#finished_list[@]}+ fi+}++function check_loss_eval(){+ term='Evaluation losses: {('+ finished_list=()+ TASK_ID_LIST=(img 144p_vid 240p_vid 360p_vid 480p_vid 720p_vid)+ for i in "${!TASK_ID_LIST[@]}"; do+ last_line=$(tail -n 1 ${LOG_BASE}/${TASK_ID_LIST[i]}.log)+ if [[ $last_line == *${term}* ]];+ then+ finished_list+=(${TASK_ID_LIST[i]})+ fi+ done++ echo "completed tasks: ${finished_list[@]}"++ if [ ${#finished_list[@]}=$loss_ready_count ];+ then+ loss_eval_ready=1+ else+ echo ${#finished_list[@]}+ fi+}++function check_vbench_gen(){+ term='Runtime:'+ finished_list=()+ TASK_ID_LIST=(4a 4b 4c 4d 4e 4f 4g 4h)+ for i in "${!TASK_ID_LIST[@]}"; do+ last_line=$(tail -n 1 ${LOG_BASE}/${TASK_ID_LIST[i]}.log)+ if [[ $last_line == *${term}* ]];+ then+ finished_list+=(${TASK_ID_LIST[i]})+ fi+ done++ echo "completed tasks: ${finished_list[@]}"++ if [ ${#finished_list[@]}=$vbench_gen_ready_count ];+ then+ vbench_gen_ready=1+ else+ echo ${#finished_list[@]}+ fi+}++function check_vbench_calc(){+ term='Runtime:'+ finished_list=()+ TASK_ID_LIST=(calc_vbench_a calc_vbench_b calc_vbench_c calc_vbench_d calc_vbench_e calc_vbench_f calc_vbench_g calc_vbench_h)+ for i in "${!TASK_ID_LIST[@]}"; do+ last_line=$(tail -n 1 ${LOG_BASE}/${TASK_ID_LIST[i]}.log)+ if [[ $last_line == *${term}* ]];+ then+ finished_list+=(${TASK_ID_LIST[i]})+ fi+ done++ echo "completed tasks: ${finished_list[@]}"++ if [ ${#finished_list[@]}=$vbench_calc_ready_count ];+ then+ vbench_calc_ready=1+ else+ echo ${#finished_list[@]}+ fi+}++function check_vbench_i2v_gen(){+ term='Runtime:'+ finished_list=()+ TASK_ID_LIST=(5a 5b 5c 5d 5e 5f 5g 5h)+ for i in "${!TASK_ID_LIST[@]}"; do+ last_line=$(tail -n 1 ${LOG_BASE}/${TASK_ID_LIST[i]}.log)+ if [[ $last_line == *${term}* ]];+ then+ finished_list+=(${TASK_ID_LIST[i]})+ fi+ done++ echo "completed tasks: ${finished_list[@]}"++ if [ ${#finished_list[@]}=$vbench_i2v_gen_ready_count ];+ then+ vbench_i2v_gen_ready=1+ else+ echo ${#finished_list[@]}+ fi+}++function check_vbench_i2v_calc(){+ term='Runtime:'+ finished_list=()+ TASK_ID_LIST=(calc_vbench_i2v_a calc_vbench_i2v_b calc_vbench_i2v_c calc_vbench_i2v_d calc_vbench_i2v_e calc_vbench_i2v_f calc_vbench_i2v_g calc_vbench_i2v_h)+ for i in "${!TASK_ID_LIST[@]}"; do+ last_line=$(tail -n 1 ${LOG_BASE}/${TASK_ID_LIST[i]}.log)+ if [[ $last_line == *${term}* ]];+ then+ finished_list+=(${TASK_ID_LIST[i]})+ fi+ done++ echo "completed tasks: ${finished_list[@]}"++ if [ ${#finished_list[@]}=$vbench_calc_ready_count ];+ then+ vbench_calc_ready=1+ else+ echo ${#finished_list[@]}+ fi+}+++### ===== Main =====++start=$(date +%s)++# ### human eval, ~60min+# echo "$(date): running human eval"+# bash eval/human_eval/launch.sh $CKPT $NUM_FRAMES $MODEL_NAME+# while [ $human_eval_ready -eq 0 ]+# do+# sleep ${sleep_time}+# check_human_eval+# done++# ### eval loss, ~160min+# echo "$(date): running eval loss"+# bash eval/eval_loss/launch.sh $CKPT $MODEL_NAME+# while [ $loss_eval_ready -eq 0 ]+# do+# sleep ${sleep_time}+# check_loss_eval+# done+# python eval/loss/tabulate_rl_loss.py --log_dir $LOG_BASE++# ### vbench gen, ~80min+# echo "$(date): running vbench gen"+# bash eval/vbench/launch.sh $CKPT $NUM_FRAMES $MODEL_NAME+# while [ $vbench_gen_ready -eq 0 ]+# do+# sleep ${sleep_time}+# check_vbench_gen+# done++# ### vbench calc, ~30min+# echo "$(date): running vbench calc"+# bash eval/vbench/launch_calc.sh $VBENCH_SAMPLE_DIR $LOG_BASE+# while [ $vbench_calc_ready -eq 0 ]+# do+# sleep ${sleep_time}+# check_vbench_calc+# done+# python eval/vbench/tabulate_vbench_scores.py --score_dir ${LOG_BASE}/vbench++### vbench_i2v gen, ~65min+echo "$(date): running vbench_i2v gen"+bash eval/vbench_i2v/launch.sh $CKPT $NUM_FRAMES $MODEL_NAME+while [ $vbench_i2v_gen_ready -eq 0 ]+do+ sleep ${sleep_time}+ check_vbench_i2v_gen+done++### vbench_i2v calc, ~48min+echo "$(date): running vbench_i2v calc"+bash eval/vbench_i2v/launch_calc.sh $VBENCH_SAMPLE_DIR $LOG_BASE+while [ $vbench_i2v_calc_ready -eq 0 ]+do+ sleep ${sleep_time}+ check_vbench_i2v_calc+done+python eval/vbench_i2v/tabulate_vbench_i2v_scores.py --score_dir ${LOG_BASE}/vbench_i2v++### End+echo "$(date): eval completed for ${CKPT}"+end=$(date +%s)+runtime=$((end - start))+echo "Runtime: $runtime seconds"