Open-Sora: Democratizing Efficient Video Production for All
Python
update scoring
pxy98f4b89f7959
diff --git a/tools/scoring/aesthetic/inference.py b/tools/scoring/aesthetic/inference.pyindex 5d791c1..8e0c19d 100644--- a/tools/scoring/aesthetic/inference.py+++ b/tools/scoring/aesthetic/inference.py@@ -118,13 +118,13 @@ class AestheticScorer(nn.Module):def main():args = parse_args()- dist.init_process_group(backend="nccl", timeout=timedelta(hours=24))- torch.cuda.set_device(dist.get_rank() % torch.cuda.device_count())-meta_path = args.meta_pathwo_ext, ext = os.path.splitext(meta_path)out_path = f"{wo_ext}_aes{ext}"+ dist.init_process_group(backend="nccl", timeout=timedelta(hours=24))+ torch.cuda.set_device(dist.get_rank() % torch.cuda.device_count())+# build modeldevice = "cuda" if torch.cuda.is_available() else "cpu"model = AestheticScorer(768, device)@@ -170,7 +170,9 @@ def main():# save local resultsmeta_local = merge_scores([(indices_list, scores_list)], dataset.meta, column="aes")- out_path_local = out_path.replace(".csv", f"_part_{dist.get_rank()}.csv")+ save_dir_local = os.path.join(os.path.dirname(out_path), 'parts')+ os.makedirs(save_dir_local, exist_ok=True)+ out_path_local = os.path.join(save_dir_local, os.path.basename(out_path).replace(".csv", f"_part_{dist.get_rank()}.csv"))meta_local.to_csv(out_path_local, index=False)# wait for all ranks to finish data processingdiff --git a/tools/scoring/optical_flow/inference.py b/tools/scoring/optical_flow/inference.pyindex 2ea0d7a..5ffa2d9 100644--- a/tools/scoring/optical_flow/inference.py+++ b/tools/scoring/optical_flow/inference.py@@ -78,15 +78,15 @@ class VideoTextDataset(torch.utils.data.Dataset):def main():args = parse_args()+ meta_path = args.meta_path+ wo_ext, ext = os.path.splitext(meta_path)+ out_path = f"{wo_ext}_flow{ext}"+torch.backends.cudnn.deterministic = Truetorch.backends.cudnn.benchmark = Falsedist.init_process_group(backend="nccl", timeout=timedelta(hours=24))torch.cuda.set_device(dist.get_rank() % torch.cuda.device_count())- meta_path = args.meta_path- wo_ext, ext = os.path.splitext(meta_path)- out_path = f"{wo_ext}_flow{ext}"-# build modeldevice = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")model = UniMatch(@@ -152,7 +152,9 @@ def main():# save local resultsmeta_local = merge_scores([(indices_list, scores_list)], dataset.meta, column="flow")- out_path_local = out_path.replace(".csv", f"_part_{dist.get_rank()}.csv")+ save_dir_local = os.path.join(os.path.dirname(out_path), 'parts')+ os.makedirs(save_dir_local, exist_ok=True)+ out_path_local = os.path.join(save_dir_local, os.path.basename(out_path).replace(".csv", f"_part_{dist.get_rank()}.csv"))meta_local.to_csv(out_path_local, index=False)# wait for all ranks to finish data processing