Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -627,14 +627,17 @@ def upload_to_huggingface(model_path, hf_token, orgs_name, model_name, make_priv
|
|
| 627 |
if not os.path.exists(model_path):
|
| 628 |
raise ValueError("Model path does not exist.")
|
| 629 |
|
| 630 |
-
#
|
| 631 |
-
repo_id = f"{orgs_name}/{model_name}" if orgs_name else model_name
|
| 632 |
api = HfApi()
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
api.
|
| 636 |
-
|
| 637 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 638 |
|
| 639 |
# Push model files
|
| 640 |
api.upload_folder(
|
|
@@ -645,9 +648,8 @@ def upload_to_huggingface(model_path, hf_token, orgs_name, model_name, make_priv
|
|
| 645 |
ignore_patterns=".ipynb_checkpoints",
|
| 646 |
)
|
| 647 |
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
return f"Model uploaded to: https://huggingface.co/{repo_id}"
|
| 651 |
except Exception as e:
|
| 652 |
error_msg = f"❌ Error during upload: {str(e)}"
|
| 653 |
print(error_msg)
|
|
|
|
| 627 |
if not os.path.exists(model_path):
|
| 628 |
raise ValueError("Model path does not exist.")
|
| 629 |
|
| 630 |
+
# Check if repo already exists
|
|
|
|
| 631 |
api = HfApi()
|
| 632 |
+
repo_id = f"{orgs_name}/{model_name}" if orgs_name else model_name
|
| 633 |
+
try:
|
| 634 |
+
api.repo_info(repo_id)
|
| 635 |
+
print(f"⚠️ Repository '{repo_id}' already exists. Proceeding with upload.")
|
| 636 |
+
except Exception:
|
| 637 |
+
if make_private:
|
| 638 |
+
api.create_repo(repo_id, private=True)
|
| 639 |
+
else:
|
| 640 |
+
api.create_repo(repo_id)
|
| 641 |
|
| 642 |
# Push model files
|
| 643 |
api.upload_folder(
|
|
|
|
| 648 |
ignore_patterns=".ipynb_checkpoints",
|
| 649 |
)
|
| 650 |
|
| 651 |
+
print(f"Model uploaded to: https://huggingface.co/{repo_id}")
|
| 652 |
+
return f"Model uploaded to: https://huggingface.co/{repo_id}"
|
|
|
|
| 653 |
except Exception as e:
|
| 654 |
error_msg = f"❌ Error during upload: {str(e)}"
|
| 655 |
print(error_msg)
|