First check repo-id is valid

This commit is contained in:
litagin02
2024-02-22 09:42:42 +09:00
parent f8a1d98c6f
commit a6a7a30fc6
2 changed files with 54 additions and 24 deletions

View File

@@ -163,6 +163,30 @@ def run():
config.out_dir: The directory for model assets of this model (for inference).
default: `model_assets/{model_name}`.
"""
if args.repo_id is not None:
# First try to upload config.json to check if the repo exists
try:
api.upload_file(
path_or_fileobj=args.config,
path_in_repo=f"Data/{config.model_name}/config.json",
repo_id=hps.repo_id,
)
except Exception as e:
logger.error(e)
logger.error(
f"Failed to upload files to the repo {hps.repo_id}. Please check if the repo exists and you have logged in using `huggingface-cli login`."
)
raise e
# Upload Data dir for resuming training
api.upload_folder(
repo_id=hps.repo_id,
folder_path=config.dataset_path,
path_in_repo=f"Data/{config.model_name}",
delete_patterns="*.pth", # Only keep the latest checkpoint
ignore_patterns=f"{config.dataset_path}/raw", # Ignore raw data
run_as_future=True,
)
os.makedirs(config.out_dir, exist_ok=True)
if not args.skip_default_style:
@@ -175,16 +199,6 @@ def run():
os.path.join(config.out_dir, "style_vectors.npy"),
)
if args.repo_id is not None:
# Upload Dataset
api.upload_folder(
repo_id=hps.repo_id,
folder_path=config.dataset_path,
path_in_repo=f"Data/{config.model_name}",
delete_patterns="*.pth",
run_as_future=True,
)
torch.manual_seed(hps.train.seed)
torch.cuda.set_device(local_rank)
@@ -589,7 +603,8 @@ def run():
repo_id=hps.repo_id,
folder_path=config.dataset_path,
path_in_repo=f"Data/{config.model_name}",
delete_patterns="*.pth",
delete_patterns="*.pth", # Only keep the latest checkpoint
ignore_patterns=f"{config.dataset_path}/raw", # Ignore raw data
run_as_future=True,
)
future2 = api.upload_folder(
@@ -959,7 +974,8 @@ def train_and_evaluate(
repo_id=hps.repo_id,
folder_path=config.dataset_path,
path_in_repo=f"Data/{config.model_name}",
delete_patterns="*.pth",
delete_patterns="*.pth", # Only keep the latest checkpoint
ignore_patterns=f"{config.dataset_path}/raw", # Ignore raw data
run_as_future=True,
)
api.upload_folder(