Spaces:
Running
Running
Update app.py
Browse filesRemoved validate and added:
# ---------------------- UPLOAD FUNCTION ----------------------
def create_model_repo(api, user, orgs_name, model_name, make_private=False):
"""Creates a Hugging Face model repository if it doesn't exist."""
repo_id = f"{orgs_name}/{model_name.strip()}" if orgs_name else f"{user['name']}/{model_name.strip()}"
try:
# Attempt to create the repository
api.create_repo(repo_id=repo_id, repo_type="model", private=make_private)
print(f"Model repo '{repo_id}' created.")
except HfHubHTTPError:
print(f"Model repo '{repo_id}' already exists.")
return repo_id
app.py
CHANGED
|
@@ -20,7 +20,7 @@ import shutil
|
|
| 20 |
import hashlib
|
| 21 |
from datetime import datetime
|
| 22 |
from typing import Dict, List, Optional
|
| 23 |
-
from huggingface_hub import login, HfApi,
|
| 24 |
|
| 25 |
# ---------------------- DEPENDENCIES ----------------------
|
| 26 |
def install_dependencies_gradio():
|
|
@@ -62,7 +62,7 @@ def increment_filename(filename):
|
|
| 62 |
counter += 1
|
| 63 |
return filename
|
| 64 |
|
| 65 |
-
# ---------------------- UPLOAD FUNCTION ----------------------
|
| 66 |
def create_model_repo(api, user, orgs_name, model_name, make_private=False):
|
| 67 |
"""Creates a Hugging Face model repository if it doesn't exist."""
|
| 68 |
repo_id = f"{orgs_name}/{model_name.strip()}" if orgs_name else f"{user['name']}/{model_name.strip()}"
|
|
|
|
| 20 |
import hashlib
|
| 21 |
from datetime import datetime
|
| 22 |
from typing import Dict, List, Optional
|
| 23 |
+
from huggingface_hub import login, HfApi, HfHubHTTPError
|
| 24 |
|
| 25 |
# ---------------------- DEPENDENCIES ----------------------
|
| 26 |
def install_dependencies_gradio():
|
|
|
|
| 62 |
counter += 1
|
| 63 |
return filename
|
| 64 |
|
| 65 |
+
# ---------------------- UPLOAD FUNCTION ----------------------# ---------------------- UPLOAD FUNCTION ----------------------
|
| 66 |
def create_model_repo(api, user, orgs_name, model_name, make_private=False):
|
| 67 |
"""Creates a Hugging Face model repository if it doesn't exist."""
|
| 68 |
repo_id = f"{orgs_name}/{model_name.strip()}" if orgs_name else f"{user['name']}/{model_name.strip()}"
|