Spaces:
Sleeping
Sleeping
Update train_model.py
Browse files- train_model.py +3 -3
train_model.py
CHANGED
|
@@ -5,7 +5,7 @@ import gc
|
|
| 5 |
from pathlib import Path
|
| 6 |
from diffusers import StableDiffusionPipeline
|
| 7 |
from accelerate.utils import set_seed
|
| 8 |
-
from huggingface_hub import HfApi,
|
| 9 |
|
| 10 |
|
| 11 |
def ensure_repo_exists(repo_id: str, hf_token: str):
|
|
@@ -13,8 +13,8 @@ def ensure_repo_exists(repo_id: str, hf_token: str):
|
|
| 13 |
try:
|
| 14 |
api.repo_info(repo_id, token=hf_token)
|
| 15 |
print(f"ℹ️ Repo '{repo_id}' already exists.")
|
| 16 |
-
except
|
| 17 |
-
if
|
| 18 |
create_repo(repo_id=repo_id, token=hf_token, repo_type="dataset", private=False)
|
| 19 |
print(f"✅ Repo '{repo_id}' created.")
|
| 20 |
else:
|
|
|
|
| 5 |
from pathlib import Path
|
| 6 |
from diffusers import StableDiffusionPipeline
|
| 7 |
from accelerate.utils import set_seed
|
| 8 |
+
from huggingface_hub import HfApi, create_repo
|
| 9 |
|
| 10 |
|
| 11 |
def ensure_repo_exists(repo_id: str, hf_token: str):
|
|
|
|
| 13 |
try:
|
| 14 |
api.repo_info(repo_id, token=hf_token)
|
| 15 |
print(f"ℹ️ Repo '{repo_id}' already exists.")
|
| 16 |
+
except Exception as e:
|
| 17 |
+
if "404" in str(e):
|
| 18 |
create_repo(repo_id=repo_id, token=hf_token, repo_type="dataset", private=False)
|
| 19 |
print(f"✅ Repo '{repo_id}' created.")
|
| 20 |
else:
|