Spaces:
Sleeping
Sleeping
Joseph Pollack
commited on
attempts to replace autogenerated model card with template readme.md
Browse files- scripts/push_to_huggingface.py +14 -13
scripts/push_to_huggingface.py
CHANGED
|
@@ -580,21 +580,22 @@ MIT License
|
|
| 580 |
if results is None:
|
| 581 |
results = self._load_training_results()
|
| 582 |
|
| 583 |
-
# Create and
|
| 584 |
model_card = self.create_model_card(training_config, results)
|
| 585 |
-
|
| 586 |
-
with open(model_card_path, "w", encoding="utf-8") as f:
|
| 587 |
-
f.write(model_card)
|
| 588 |
-
|
| 589 |
try:
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 598 |
|
| 599 |
# Upload model files
|
| 600 |
if not self.upload_model_files():
|
|
|
|
| 580 |
if results is None:
|
| 581 |
results = self._load_training_results()
|
| 582 |
|
| 583 |
+
# Create model card and persist it inside the model directory as README.md
|
| 584 |
model_card = self.create_model_card(training_config, results)
|
| 585 |
+
local_readme_path = self.model_path / "README.md"
|
|
|
|
|
|
|
|
|
|
| 586 |
try:
|
| 587 |
+
with open(local_readme_path, "w", encoding="utf-8") as f:
|
| 588 |
+
f.write(model_card)
|
| 589 |
+
except Exception as e:
|
| 590 |
+
logger.warning(f"⚠️ Could not write README.md to model directory: {e}")
|
| 591 |
+
|
| 592 |
+
# Upload README.md from the model directory
|
| 593 |
+
upload_file(
|
| 594 |
+
path_or_fileobj=str(local_readme_path) if local_readme_path.exists() else model_card,
|
| 595 |
+
path_in_repo="README.md",
|
| 596 |
+
repo_id=self.repo_id,
|
| 597 |
+
token=self.token
|
| 598 |
+
)
|
| 599 |
|
| 600 |
# Upload model files
|
| 601 |
if not self.upload_model_files():
|