Open-Sora: Democratizing Efficient Video Production for All
Python
complete eval pipeline (#53)
Zheng Zangwei (Alex Zheng)1f99b9ba4b4f
diff --git a/.gitignore b/.gitignoreindex 8797ae7..a64a359 100644--- a/.gitignore+++ b/.gitignore@@ -170,6 +170,7 @@ runs/checkpoints/outputs/samples/+sampleslogs/pretrained_models/*.swpdiff --git a/assets/texts/t2v_ref.txt b/assets/texts/t2v_ref.txtnew file mode 100644index 0000000..49252b6--- /dev/null+++ b/assets/texts/t2v_ref.txt@@ -0,0 +1,5 @@+Drone view of waves crashing against the rugged cliffs along Big Sur’s garay point beach. The crashing blue waters create white-tipped waves, while the golden light of the setting sun illuminates the rocky shore. A small island with a lighthouse sits in the distance, and green shrubbery covers the cliff’s edge. The steep drop from the road down to the beach is a dramatic feat, with the cliff's edges jutting out over the sea. This is a view that captures the raw beauty of the coast and the rugged landscape of the Pacific Coast Highway.+In an ornate, historical hall, a massive tidal wave peaks and begins to crash. Two surfers, seizing the moment, skillfully navigate the face of the wave.+Pirate ship in a cosmic maelstrom nebula.+Drone view of waves crashing against the rugged cliffs along Big Sur’s garay point beach. The crashing blue waters create white-tipped waves, while the golden light of the setting sun illuminates the rocky shore. A small island with a lighthouse sits in the distance, and green shrubbery covers the cliff’s edge. The steep drop from the road down to the beach is a dramatic feat, with the cliff's edges jutting out over the sea. This is a view that captures the raw beauty of the coast and the rugged landscape of the Pacific Coast Highway.+A sad small cactus with in the Sahara desert becomes happy.diff --git a/configs/dit/inference/16x256x256.py b/configs/dit/inference/16x256x256.pyindex e9dc2f6..44818fe 100644--- a/configs/dit/inference/16x256x256.py+++ b/configs/dit/inference/16x256x256.py@@ -28,4 +28,4 @@ dtype = "bf16"batch_size = 2seed = 42prompt_path = "./assets/texts/ucf101_labels.txt"-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/dit/inference/1x256x256-class.py b/configs/dit/inference/1x256x256-class.pyindex 326e4d4..bebaa11 100644--- a/configs/dit/inference/1x256x256-class.py+++ b/configs/dit/inference/1x256x256-class.py@@ -28,4 +28,4 @@ dtype = "bf16"batch_size = 2seed = 42prompt_path = "./assets/texts/imagenet_id.txt"-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/dit/inference/1x256x256.py b/configs/dit/inference/1x256x256.pyindex 8f9ce67..e7cb9a2 100644--- a/configs/dit/inference/1x256x256.py+++ b/configs/dit/inference/1x256x256.py@@ -29,4 +29,4 @@ dtype = "bf16"batch_size = 2seed = 42prompt_path = "./assets/texts/imagenet_labels.txt"-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/latte/inference/16x256x256-class.py b/configs/latte/inference/16x256x256-class.pyindex 44766e2..8ccf6d4 100644--- a/configs/latte/inference/16x256x256-class.py+++ b/configs/latte/inference/16x256x256-class.py@@ -27,4 +27,4 @@ dtype = "bf16"batch_size = 2seed = 42prompt_path = "./assets/texts/ucf101_id.txt"-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/latte/inference/16x256x256.py b/configs/latte/inference/16x256x256.pyindex 3cfe273..6bdd58f 100644--- a/configs/latte/inference/16x256x256.py+++ b/configs/latte/inference/16x256x256.py@@ -28,4 +28,4 @@ dtype = "bf16"batch_size = 2seed = 42prompt_path = "./assets/texts/ucf101_labels.txt"-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/opensora-v1-1/inference/sample-ref.py b/configs/opensora-v1-1/inference/sample-ref.pynew file mode 100644index 0000000..9fce4a0--- /dev/null+++ b/configs/opensora-v1-1/inference/sample-ref.py@@ -0,0 +1,54 @@+num_frames = 16+fps = 24 // 3+image_size = (240, 426)+multi_resolution = "STDiT2"++# Condition+prompt_path = None+prompt = None++loop = 10+condition_frame_length = 4+reference_path = [+ "assets/images/condition/cliff.png",+ "assets/images/condition/wave.png",+]+# valid when reference_path is not None+# (loop id, ref id, ref start, length, target start)+mask_strategy = [+ "0,0,0,1,0",+ "0,0,0,1,0",+]++# Define model+model = dict(+ type="STDiT2-XL/2",+ from_pretrained=None,+ input_sq_size=512,+ enable_flashattn=True,+ enable_layernorm_kernel=True,+)+vae = dict(+ type="VideoAutoencoderKL",+ from_pretrained="stabilityai/sd-vae-ft-ema",+ cache_dir=None, # "/mnt/hdd/cached_models",+ micro_batch_size=4,+)+text_encoder = dict(+ type="t5",+ from_pretrained="DeepFloyd/t5-v1_1-xxl",+ cache_dir=None, # "/mnt/hdd/cached_models",+ model_max_length=200,+)+scheduler = dict(+ type="iddpm",+ num_sampling_steps=100,+ cfg_scale=7.0,+ cfg_channel=3, # or None+)+dtype = "bf16"++# Others+batch_size = 1+seed = 42+save_dir = "./samples/samples/"diff --git a/configs/opensora-v1-1/inference/sample.py b/configs/opensora-v1-1/inference/sample.pyindex 43c8254..0d16f51 100644--- a/configs/opensora-v1-1/inference/sample.py+++ b/configs/opensora-v1-1/inference/sample.py@@ -1,6 +1,6 @@num_frames = 16fps = 24 // 3-image_size = (256, 256)+image_size = (240, 426)multi_resolution = "STDiT2"# Define model@@ -38,4 +38,4 @@ prompt = None # prompt has higher priority than prompt_path# Othersbatch_size = 1seed = 42-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/opensora/inference-long/16x256x256-extend.py b/configs/opensora/inference-long/16x256x256-extend.pyindex 109ac34..dd42ce2 100644--- a/configs/opensora/inference-long/16x256x256-extend.py+++ b/configs/opensora/inference-long/16x256x256-extend.py@@ -52,4 +52,4 @@ mask_strategy = [# Othersbatch_size = 2seed = 42-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/opensora/inference-long/16x512x512-annimate.py b/configs/opensora/inference-long/16x512x512-annimate.pyindex 636e652..b0ba959 100644--- a/configs/opensora/inference-long/16x512x512-annimate.py+++ b/configs/opensora/inference-long/16x512x512-annimate.py@@ -47,4 +47,4 @@ mask_strategy = ["0,0,0,1,0", "0,0,0,1,0"] # valid when reference_path is not N# Othersbatch_size = 2seed = 42-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/opensora/inference-long/16x512x512-connect.py b/configs/opensora/inference-long/16x512x512-connect.pyindex 248a914..c5383f1 100644--- a/configs/opensora/inference-long/16x512x512-connect.py+++ b/configs/opensora/inference-long/16x512x512-connect.py@@ -50,4 +50,4 @@ mask_strategy = ["0,0,0,1,0;0,0,0,1,-1", "0,0,0,1,0;0,1,0,1,-1"] # valid when r# Othersbatch_size = 2seed = 42-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/opensora/inference-long/16x512x512-extend.py b/configs/opensora/inference-long/16x512x512-extend.pyindex ab77e18..9c3309a 100644--- a/configs/opensora/inference-long/16x512x512-extend.py+++ b/configs/opensora/inference-long/16x512x512-extend.py@@ -47,4 +47,4 @@ mask_strategy = ["0,0,0,1,0", "0,0,0,1,0"] # valid when reference_path is not N# Othersbatch_size = 2seed = 42-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/opensora/inference/16x256x256.py b/configs/opensora/inference/16x256x256.pyindex 8a5de29..50ead83 100644--- a/configs/opensora/inference/16x256x256.py+++ b/configs/opensora/inference/16x256x256.py@@ -36,4 +36,4 @@ prompt = None # prompt has higher priority than prompt_path# Othersbatch_size = 1seed = 42-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/opensora/inference/16x512x512.py b/configs/opensora/inference/16x512x512.pyindex 7e05a86..58d8243 100644--- a/configs/opensora/inference/16x512x512.py+++ b/configs/opensora/inference/16x512x512.py@@ -32,4 +32,4 @@ dtype = "bf16"batch_size = 2seed = 42prompt_path = "./assets/texts/t2v_samples.txt"-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/opensora/inference/64x512x512.py b/configs/opensora/inference/64x512x512.pyindex 2d7c5e2..dbbe240 100644--- a/configs/opensora/inference/64x512x512.py+++ b/configs/opensora/inference/64x512x512.py@@ -32,4 +32,4 @@ dtype = "bf16"batch_size = 1seed = 42prompt_path = "./assets/texts/t2v_samples.txt"-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/pixart/inference/16x256x256.py b/configs/pixart/inference/16x256x256.pyindex f8b0d36..5013c08 100644--- a/configs/pixart/inference/16x256x256.py+++ b/configs/pixart/inference/16x256x256.py@@ -29,4 +29,4 @@ dtype = "bf16"batch_size = 2seed = 42prompt_path = "./assets/texts/t2v_samples.txt"-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/pixart/inference/1x1024MS.py b/configs/pixart/inference/1x1024MS.pyindex 9ab7656..e6af8c6 100644--- a/configs/pixart/inference/1x1024MS.py+++ b/configs/pixart/inference/1x1024MS.py@@ -31,4 +31,4 @@ dtype = "bf16"batch_size = 2seed = 42prompt_path = "./assets/texts/t2i_samples.txt"-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/pixart/inference/1x256x256.py b/configs/pixart/inference/1x256x256.pyindex 5e7b276..16f9260 100644--- a/configs/pixart/inference/1x256x256.py+++ b/configs/pixart/inference/1x256x256.py@@ -30,4 +30,4 @@ dtype = "bf16"batch_size = 2seed = 42prompt_path = "./assets/texts/t2i_samples.txt"-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/configs/pixart/inference/1x512x512.py b/configs/pixart/inference/1x512x512.pyindex 8c17191..dbc90df 100644--- a/configs/pixart/inference/1x512x512.py+++ b/configs/pixart/inference/1x512x512.py@@ -36,4 +36,4 @@ prompt = [# Othersbatch_size = 2seed = 42-save_dir = "./outputs/samples/"+save_dir = "./samples/samples/"diff --git a/docs/commands.md b/docs/commands.mdindex 7827cd9..92adf66 100644--- a/docs/commands.md+++ b/docs/commands.md@@ -71,6 +71,19 @@ vae = dict()```+### Evalution++Use the following commands to generate predefined samples.++```bash+# image+bash scripts/misc/sample.sh /path/to/ckpt --image+# video+bash scripts/misc/sample.sh /path/to/ckpt --video+# video edit+bash scripts/misc/sample.sh /path/to/ckpt --video-edit+```+## TrainingTo resume training, run the following command. ``--load`` different from ``--ckpt-path`` as it loads the optimizer and dataloader states.@@ -109,6 +122,7 @@ python tools/datasets/split.py YOUR_CSV_PATH -o YOUR_SUBSET_CSV_PATH -c configs/If you want to control the batch size search more granularly, you can configure batch size start, end, and step in the config file.Bucket config format:+1. `{ resolution: {num_frames: (prob, batch_size)} }`, in this case batch_size is ignored when searching2. `{ resolution: {num_frames: (prob, (max_batch_size, ))} }`, batch_size is searched in the range `[batch_size_start, max_batch_size)`, batch_size_start is configured via CLI3. `{ resolution: {num_frames: (prob, (min_batch_size, max_batch_size))} }`, batch_size is searched in the range `[min_batch_size, max_batch_size)`@@ -135,4 +149,4 @@ bucket_config = {}```-It will print the best batch size (and corresponding step time) for each bucket and save the output config file.\ No newline at end of file+It will print the best batch size (and corresponding step time) for each bucket and save the output config file.diff --git a/notebooks/launch.ipynb b/notebooks/launch.ipynbindex a405eec..29dfafb 100644--- a/notebooks/launch.ipynb+++ b/notebooks/launch.ipynb@@ -20,6 +20,8 @@"metadata": {},"outputs": [],"source": [+ "import os\n",+ "\n","OPEN_SORA_HOME = \"/home/zhaowangbo/zangwei/opensora/\"\n","\n","\n",@@ -47,6 +49,7 @@" )\n"," return \" && \".join(commands), output_file\n","\n",+ "\n","def get_video_info_torchvision(input_file):\n"," commands = []\n"," base, ext = os.path.splitext(input_file)\n",@@ -173,9 +176,7 @@"metadata": {},"outputs": [],"source": [- "import os\n","import paramiko\n",- "import time\n","\n","HOSTS = [\"h800-80\", \"h800-81\", \"h800-82\", \"h800-83\", \"h800-84\", \"h800-85\", \"h800-86\", \"h800-170\", \"h800-171\"]\n","\n",diff --git a/opensora/datasets/utils.py b/opensora/datasets/utils.pyindex ba205cb..907ba6a 100644--- a/opensora/datasets/utils.py+++ b/opensora/datasets/utils.py@@ -86,32 +86,32 @@ def get_transforms_image(name="center", image_size=(256, 256)):return transform-def read_image_from_path(path, transform=None, num_frames=1, image_size=(256, 256)):+def read_image_from_path(path, transform=None, transform_name="center", num_frames=1, image_size=(256, 256)):image = pil_loader(path)if transform is None:- transform = get_transforms_image(image_size=image_size)+ transform = get_transforms_image(image_size=image_size, name=transform_name)image = transform(image)video = image.unsqueeze(0).repeat(num_frames, 1, 1, 1)video = video.permute(1, 0, 2, 3)return video-def read_video_from_path(path, transform=None, image_size=(256, 256)):+def read_video_from_path(path, transform=None, transform_name="center", image_size=(256, 256)):vframes, aframes, info = torchvision.io.read_video(filename=path, pts_unit="sec", output_format="TCHW")if transform is None:- transform = get_transforms_video(image_size=image_size)+ transform = get_transforms_video(image_size=image_size, name=transform_name)video = transform(vframes) # T C H Wvideo = video.permute(1, 0, 2, 3)return video-def read_from_path(path, image_size):+def read_from_path(path, image_size, transform_name="center"):ext = os.path.splitext(path)[-1].lower()if ext.lower() in VID_EXTENSIONS:- return read_video_from_path(path, image_size=image_size)+ return read_video_from_path(path, image_size=image_size, transform_name=transform_name)else:assert ext.lower() in IMG_EXTENSIONS, f"Unsupported file format: {ext}"- return read_image_from_path(path, image_size=image_size)+ return read_image_from_path(path, image_size=image_size, transform_name=transform_name)def save_sample(x, fps=8, save_path=None, normalize=True, value_range=(-1, 1)):diff --git a/opensora/utils/config_utils.py b/opensora/utils/config_utils.pyindex 6b793ac..ecd1b90 100644--- a/opensora/utils/config_utils.py+++ b/opensora/utils/config_utils.py@@ -38,6 +38,7 @@ def parse_args(training=False):# promptparser.add_argument("--prompt-path", default=None, type=str, help="path to prompt txt file")+ parser.add_argument("--prompt", default=None, type=str, nargs="+", help="prompt list")# image/videoparser.add_argument("--num-frames", default=None, type=int, help="number of frames")@@ -47,6 +48,12 @@ def parse_args(training=False):# hyperparametersparser.add_argument("--num-sampling-steps", default=None, type=int, help="sampling steps")parser.add_argument("--cfg-scale", default=None, type=float, help="balance between cond & uncond")++ # reference+ parser.add_argument("--loop", default=None, type=int, help="loop")+ parser.add_argument("--condition-frame-length", default=None, type=int, help="condition frame length")+ parser.add_argument("--reference-path", default=None, type=str, nargs="+", help="reference path")+ parser.add_argument("--mask-strategy", default=None, type=str, nargs="+", help="mask strategy")# ======================================================# Training# ======================================================@@ -62,17 +69,22 @@ def merge_args(cfg, args, training=False):if args.ckpt_path is not None:cfg.model["from_pretrained"] = args.ckpt_pathargs.ckpt_path = None+ if training and args.data_path is not None:+ cfg.dataset["data_path"] = args.data_path+ args.data_path = Nonefor k, v in vars(args).items():- if k in cfg and v is not None:+ if v is not None:cfg[k] = vif not training:# Inference only+ # - Allow not setif "reference_path" not in cfg:cfg["reference_path"] = Noneif "loop" not in cfg:cfg["loop"] = 1+ # - Prompt handlingif "prompt" not in cfg or cfg["prompt"] is None:assert cfg["prompt_path"] is not None, "prompt or prompt_path must be provided"cfg["prompt"] = load_prompts(cfg["prompt_path"])@@ -82,19 +94,15 @@ def merge_args(cfg, args, training=False):cfg["prompt"] = cfg["prompt"][args.start_index :]elif args.end_index is not None:cfg["prompt"] = cfg["prompt"][: args.end_index]- if "sample_name" not in cfg:- cfg["sample_name"] = Noneelse:# Training only- if args.data_path is not None:- cfg.dataset["data_path"] = args.data_path- args.data_path = None+ # - Allow not setif "mask_ratios" not in cfg:cfg["mask_ratios"] = None- if "transform_name" not in cfg.dataset:- cfg.dataset["transform_name"] = "center"if "bucket_config" not in cfg:cfg["bucket_config"] = None+ if "transform_name" not in cfg.dataset:+ cfg.dataset["transform_name"] = "center"# Both training and inferenceif "multi_resolution" not in cfg:diff --git a/requirements.txt b/requirements.txtindex f093684..d675337 100644--- a/requirements.txt+++ b/requirements.txt@@ -13,3 +13,4 @@ timmtqdmtransformerswandb+rotary_embedding_torchdiff --git a/scripts/inference-long.py b/scripts/inference-long.pyindex ab37b0c..9c7663d 100644--- a/scripts/inference-long.py+++ b/scripts/inference-long.py@@ -21,7 +21,7 @@ def collect_references_batch(reference_paths, vae, image_size):ref_path = reference_path.split(";")ref = []for r_path in ref_path:- r = read_from_path(r_path, image_size)+ r = read_from_path(r_path, image_size, transform_name="resize_crop")r_x = vae.encode(r.unsqueeze(0).to(vae.device, vae.dtype))r_x = r_x.squeeze(0)ref.append(r_x)@@ -164,6 +164,7 @@ def main():# 4. inference# ======================================================sample_idx = 0+ sample_name = cfg.sample_name if cfg.sample_name is not None else "sample"save_dir = cfg.save_diros.makedirs(save_dir, exist_ok=True)@@ -218,7 +219,7 @@ def main():]video = torch.cat(video_clips_i, dim=1)print(f"Prompt: {prompts[i + idx]}")- save_path = os.path.join(save_dir, f"sample_{sample_idx}")+ save_path = os.path.join(save_dir, f"{sample_name}_{sample_idx}")save_sample(video, fps=cfg.fps, save_path=save_path)sample_idx += 1diff --git a/scripts/misc/sample.sh b/scripts/misc/sample.shindex d7b5952..904505e 100644--- a/scripts/misc/sample.sh+++ b/scripts/misc/sample.sh@@ -1,75 +1,141 @@+#!/bin/bash+set -x+set -e++CKPT=$1-CUDA_VISIBLE_DEVICES=7CMD="python scripts/inference.py configs/opensora-v1-1/inference/sample.py"-CKPT="~/lishenggui/epoch0-global_step9000"-OUTPUT="./outputs/samples_s1_9000"--# 1. image--# 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--# 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-idx 3--# 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-idx 3--# 1.4 720p multi-resolution-# 1:1-PROMPT = "Bright scene, aerial view,ancient city, fantasy, gorgeous light, mirror reflection, high detail, wide angle lens."-eval $CMD --ckpt-path $CKPT --prompt $PROMPT --save-dir $OUTPUT --num-frames 1 --image-size 960 960 --sample-name 720p_1_1-# 16:9-eval $CMD --ckpt-path $CKPT --prompt $PROMPT --save-dir $OUTPUT --num-frames 1 --image-size 720 1280 --sample-name 720p_16_9-# 9:16-eval $CMD --ckpt-path $CKPT --prompt $PROMPT --save-dir $OUTPUT --num-frames 1 --image-size 1280 720 --sample-name 720p_9_16-# 4:3-eval $CMD --ckpt-path $CKPT --prompt $PROMPT --save-dir $OUTPUT --num-frames 1 --image-size 832 1108 --sample-name 720p_4_3-# 3:4-eval $CMD --ckpt-path $CKPT --prompt $PROMPT --save-dir $OUTPUT --num-frames 1 --image-size 1108 832 --sample-name 720p_3_4-# 1:2-eval $CMD --ckpt-path $CKPT --prompt $PROMPT --save-dir $OUTPUT --num-frames 1 --image-size 1358 600 --sample-name 720p_1_2-# 2:1-eval $CMD --ckpt-path $CKPT --prompt $PROMPT --save-dir $OUTPUT --num-frames 1 --image-size 600 1358 --sample-name 720p_2_1--# 2. video--# 1.1 16x240x426-eval $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-eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 16 --image-size 240 426 --sample-name short_16x240x426-eval $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--# 1.2 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--# 1.3 128x240x426-eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 128 --image-size 240 426 --sample-name short_128x240x426--# 1.4 16x480x854-eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 16 --image-size 480 854 --sample-name short_16x480x854--# 1.5 64x480x854-eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 64 --image-size 480 854 --sample-name short_64x480x854--# 1.6 16x720x1280-eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 16 --image-size 720 1280 --sample-name short_16x720x1280--# 1.7 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--# 3. video edit+CMD_REF="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/samples_${CKPT_BASE}"+start=$(date +%s)++### Functions++function run_image() {+ # 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++ # 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++ # 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++ # 1.4 720p multi-resolution+ # 1:1+ PROMPT="Bright scene, aerial view,ancient city, fantasy, gorgeous light, mirror reflection, high detail, wide angle lens."+ eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 1 --image-size 960 960 --sample-name 720p_1_1+ # 16:9+ eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 1 --image-size 720 1280 --sample-name 720p_16_9+ # 9:16+ eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 1 --image-size 1280 720 --sample-name 720p_9_16+ # 4:3+ eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 1 --image-size 832 1108 --sample-name 720p_4_3+ # 3:4+ eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 1 --image-size 1108 832 --sample-name 720p_3_4+ # 1:2+ eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 1 --image-size 1358 600 --sample-name 720p_1_2+ # 2:1+ eval $CMD --ckpt-path $CKPT --prompt \"$PROMPT\" --save-dir $OUTPUT --num-frames 1 --image-size 600 1358 --sample-name 720p_2_1+}++function run_video_1() {+ # 2.1.1 16x240x426+ eval $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+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 16 --image-size 240 426 --sample-name short_16x240x426+ eval $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++ # 2.1.2 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_2() {+ # 2.2.1 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++ # 2.2.2 128x240x426+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 128 --image-size 240 426 --sample-name short_128x240x426++ # 2.2.3 16x480x854+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 16 --image-size 480 854 --sample-name short_16x480x854++ # 2.2.4 64x480x854+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 64 --image-size 480 854 --sample-name short_64x480x854++ # 2.2.5 16x720x1280+ eval $CMD --ckpt-path $CKPT --prompt-path assets/texts/t2v_short.txt --save-dir $OUTPUT --num-frames 16 --image-size 720 1280 --sample-name short_16x720x1280+}++function run_video_edit() {+ # 3.1 image-conditioned long video generation+ eval $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 \+ --mask-strategy "0,0,0,1,0" "0,0,0,1,0"++ eval $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 \+ --mask-strategy "0,0,0,1,0" "0,0,0,1,0"++ # 3.2+ eval $CMD_REF --ckpt-path $CKPT --save-dir $OUTPUT --sample-name ref_L1_128x240x426 \+ --prompt-path assets/texts/t2v_ref.txt --start-index 3 --end-index 5 \+ --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" \+ --mask-strategy "0,0,0,1,0\;0,0,0,1,-1" "0,0,0,1,0\;0,1,0,1,-1"+}++### Main++for arg in "$@"; do+ if [[ "$arg" = -1 ]] || [[ "$arg" = --image ]]; then+ run_image+ echo "Running image samples..."+ fi+ if [[ "$arg" = -2_1 ]] || [[ "$arg" = --video ]]; then+ run_video_1+ echo "Running video samples 1..."+ fi+ if [[ "$arg" = -2_2 ]] || [[ "$arg" = --video ]]; then+ run_video_2+ echo "Running video samples 2..."+ fi+ if [[ "$arg" = -3 ]] || [[ "$arg" = --video-edit ]]; then+ run_video_edit+ echo "Running video edit samples..."+ fi+done++### End++end=$(date +%s)++runtime=$((end - start))+echo "Runtime: $runtime seconds"diff --git a/tools/datasets/analyze.py b/tools/datasets/analyze.pyindex 701d716..0c9cd32 100644--- a/tools/datasets/analyze.py+++ b/tools/datasets/analyze.py@@ -17,7 +17,7 @@ def read_file(input_path):def parse_args():parser = argparse.ArgumentParser()parser.add_argument("input", type=str, help="Path to the input dataset")- parser.add_argument("--save-img", type=str, default="outputs/samples/infos/", help="Path to save the image")+ parser.add_argument("--save-img", type=str, default="samples/samples/infos/", help="Path to save the image")return parser.parse_args()