Skip to content

Open-Sora: Democratizing Efficient Video Production for All

Python

add start from scratch

Zangwei Zhenge009e89e1a5f
diff --git a/opensora/utils/config_utils.py b/opensora/utils/config_utils.py
index fe05832..9e60a69 100644
--- a/opensora/utils/config_utils.py
+++ b/opensora/utils/config_utils.py
@@ -63,6 +63,7 @@ def parse_args(training=False):
parser.add_argument("--wandb", default=None, type=bool, help="enable wandb")
parser.add_argument("--load", default=None, type=str, help="path to continue training")
parser.add_argument("--data-path", default=None, type=str, help="path to data csv")
+ parser.add_argument("--start-from-scratch", action="store_true", help="start training from scratch")
return parser.parse_args()
@@ -115,6 +116,8 @@ def merge_args(cfg, args, training=False):
# - Allow not set
if "mask_ratios" not in cfg:
cfg["mask_ratios"] = None
+ if "start_from_scratch" not in cfg:
+ cfg["start_from_scratch"] = False
if "bucket_config" not in cfg:
cfg["bucket_config"] = None
if "transform_name" not in cfg.dataset:
diff --git a/scripts/train.py b/scripts/train.py
index 1884fb3..33fa7f6 100644
--- a/scripts/train.py
+++ b/scripts/train.py
@@ -204,7 +204,7 @@ def main():
optimizer,
lr_scheduler,
cfg.load,
- sampler=sampler_to_io,
+ sampler=sampler_to_io if not cfg.start_from_scratch else None,
)
logger.info(f"Loaded checkpoint {cfg.load} at epoch {start_epoch} step {start_step}")
logger.info(f"Training for {cfg.epochs} epochs with {num_steps_per_epoch} steps per epoch")