Open-Sora: Democratizing Efficient Video Production for All
Python
update
zhengzangwd262f14a2414
diff --git a/README.md b/README.mdindex 7289ba4..49ffbc8 100644--- a/README.md+++ b/README.md@@ -25,7 +25,8 @@ With Open-Sora, we aim to inspire innovation, creativity, and inclusivity in the## π° News-* **[2024.03.18]** π₯ We release **Open-Sora 1.0**, a fully open-source project for video generation.+* **[2024.04.22]** π₯ We release **Open-Sora 1.1**, which supports **2s~15s, 144p to 720p, any aspect ratio** text-to-image, **text-to-video, image-to-video and video-to-video** generation. While a [checkpoint]() is provided, our model is still under training. In addition, a full video processing pipeline is released.+* **[2024.03.18]** We release **Open-Sora 1.0**, a fully open-source project for video generation.Open-Sora 1.0 supports a full pipeline of video data preprocessing, training with<a href="https://github.com/hpcaitech/ColossalAI"><img src="assets/readme/colossal_ai.png" width="8%" ></a>acceleration,@@ -37,6 +38,11 @@ With Open-Sora, we aim to inspire innovation, creativity, and inclusivity in the## π₯ Latest Demo+TBD++<details>+<summary>OpenSora 1.0 Demo</summary>+| **2s 512Γ512** | **2s 512Γ512** | **2s 512Γ512** || ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- || [<img src="assets/readme/sample_0.gif" width="">](https://github.com/hpcaitech/Open-Sora/assets/99191637/de1963d3-b43b-4e68-a670-bb821ebb6f80) | [<img src="assets/readme/sample_1.gif" width="">](https://github.com/hpcaitech/Open-Sora/assets/99191637/13f8338f-3d42-4b71-8142-d234fbd746cc) | [<img src="assets/readme/sample_2.gif" width="">](https://github.com/hpcaitech/Open-Sora/assets/99191637/fa6a65a6-e32a-4d64-9a9e-eabb0ebb8c16) |@@ -44,19 +50,31 @@ With Open-Sora, we aim to inspire innovation, creativity, and inclusivity in the| [<img src="assets/readme/sample_3.gif" width="">](https://github.com/hpcaitech/Open-Sora/assets/99191637/64232f84-1b36-4750-a6c0-3e610fa9aa94) | [<img src="assets/readme/sample_4.gif" width="">](https://github.com/hpcaitech/Open-Sora/assets/99191637/983a1965-a374-41a7-a76b-c07941a6c1e9) | [<img src="assets/readme/sample_5.gif" width="">](https://github.com/hpcaitech/Open-Sora/assets/99191637/ec10c879-9767-4c31-865f-2e8d6cf11e65) || A bustling city street at night, filled with the glow of car headlights and the ambient light of streetlights. [...] | The vibrant beauty of a sunflower field. The sunflowers are arranged in neat rows, creating a sense of order and symmetry. [...] | A serene underwater scene featuring a sea turtle swimming through a coral reef. The turtle, with its greenish-brown shell [...] |+</details>+Videos are downsampled to `.gif` for display. Click for original videos. Prompts are trimmed for display,see [here](/assets/texts/t2v_samples.txt) for full prompts. See more samples atour [gallery](https://hpcaitech.github.io/Open-Sora/).## π New Features/Updates-* π Open-Sora-v1 released. Model weights are available [here](#model-weights). With only 400K video clips and 200 H800- days (compared with 152M samples in Stable Video Diffusion), we are able to generate 2s 512Γ512 videos.+* π+* β+* β+* β+* β+* π Open-Sora 1.0 released. Model weights are available [here](#model-weights). With only 400K video clips and 200 H800+ days (compared with 152M samples in Stable Video Diffusion), we are able to generate 2s 512Γ512 videos. See our **[report](docs/report_01.md)** for more discussions.* β Three stages training from an image diffusion model to a video diffusion model. We provide the weights for eachstage.* β Support training acceleration including accelerated transformer, faster T5 and VAE, and sequence parallelism.Open-Sora improve **55%** training speed when training on 64x512x512 videos. Details locatesat [acceleration.md](docs/acceleration.md).+++<details>+<summary>View more</summary>+* β We provide data preprocessing pipeline,including [downloading](/tools/datasets/README.md), [video cutting](/tools/scenedetect/README.md),and [captioning](/tools/caption/README.md) tools. Our data collection plan can be found@@ -72,10 +90,6 @@ our [gallery](https://hpcaitech.github.io/Open-Sora/).* β Support inference with official weightsfrom [DiT](https://github.com/facebookresearch/DiT), [Latte](https://github.com/Vchitect/Latte),and [PixArt](https://pixart-alpha.github.io/).--<details>-<summary>View more</summary>-* β Refactor the codebase. See [structure.md](docs/structure.md) to learn the project structure and how to use theconfig files.@@ -83,18 +97,17 @@ our [gallery](https://hpcaitech.github.io/Open-Sora/).### TODO list sorted by priority-* [ ] Complete the data processing pipeline (including dense optical flow, aesthetics scores, text-image similarity,- deduplication, etc.). See [datasets.md](/docs/datasets.md) for more information. **[WIP]**-* [ ] Training Video-VAE. **[WIP]**+* [ ] Training Video-VAE and adapt our model to new VAE. **[WIP]**+* [ ] Incoporate a better scheduler, e.g., rectified flow in SD3.+* [ ] Scaling model parameters and dataset size.<details><summary>View more</summary>-* [ ] Support image and video conditioning.* [ ] Evaluation pipeline.-* [ ] Incoporate a better scheduler, e.g., rectified flow in SD3.-* [ ] Support variable aspect ratios, resolutions, durations.-* [ ] Support SD3 when released.+* [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.</details>diff --git a/opensora/datasets/__init__.py b/opensora/datasets/__init__.pyindex c096ef9..545eb17 100644--- a/opensora/datasets/__init__.py+++ b/opensora/datasets/__init__.py@@ -1,3 +1,3 @@from .dataloader import prepare_dataloader, prepare_variable_dataloader-from .datasets import VariableVideoTextDataset, VideoTextDataset+from .datasets import IMG_FPS, VariableVideoTextDataset, VideoTextDatasetfrom .utils import get_transforms_image, get_transforms_video, save_samplediff --git a/opensora/utils/config_utils.py b/opensora/utils/config_utils.pyindex 0839185..51e8c8c 100644--- a/opensora/utils/config_utils.py+++ b/opensora/utils/config_utils.py@@ -85,7 +85,9 @@ def merge_args(cfg, args, training=False):if "loop" not in cfg:cfg["loop"] = 1if "frame_interval" not in cfg:- cfg["frame_interval"] = 3+ cfg["frame_interval"] = 1+ if "sample_name" not in cfg:+ cfg["sample_name"] = None# - 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"diff --git a/tools/datasets/analyze.py b/tools/datasets/analyze.pyindex 0c9cd32..7151689 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="samples/samples/infos/", help="Path to save the image")+ parser.add_argument("--save-img", type=str, default="samples/infos/", help="Path to save the image")return parser.parse_args()@@ -51,6 +51,7 @@ COLUMNS = {def main(args):data = read_file(args.input)+ # === Image Data Info ===image_index = data["num_frames"] == 1if image_index.sum() > 0:print("=== Image Data Info ===")@@ -65,10 +66,18 @@ def main(args):plot_categorical_data(img_data, column, os.path.join(args.save_img, f"image_{column}.png"))else:plot_data(img_data, column, COLUMNS[column], os.path.join(args.save_img, f"image_{column}.png"))++ # === Video Data Info ===if not image_index.all():print("=== Video Data Info ===")video_data = data[~image_index]print(f"Number of videos: {len(video_data)}")+ if "num_frames" in video_data.columns:+ total_num_frames = video_data["num_frames"].sum()+ print(f"Number of frames: {total_num_frames}")+ DEFAULT_FPS = 30+ total_hours = total_num_frames / DEFAULT_FPS / 3600+ print(f"Total hours (30 FPS): {int(total_hours)}")print(video_data.head())print(video_data.describe())if args.save_img: