voiceagents-cosyvoice2 / upload_to_hf.py
starkprince's picture
Upload folder using huggingface_hub
778d4b8 verified
#!/usr/bin/env python3
"""Upload project to Hugging Face"""
import os
from huggingface_hub import HfApi, upload_folder
# Set token
token = open("/data/huggingface/token").read().strip()
# Initialize API
api = HfApi(token=token)
# Repository details
repo_id = "starkprince/voiceagents-cosyvoice2"
repo_type = "model"
# Patterns to ignore
ignore_patterns = [
"*.git*",
".git/*",
"__pycache__/*",
"*.pyc",
"*.log",
"models/LLaMA-Omni2-3B/**",
"models/cosyvoice2/**",
"models/cosyvoice2_original/**",
"models/cosy2_decoder/**",
"*.cache/**",
"controller.log",
"worker.log",
"gradio*.log",
"nohup.out",
]
print(f"Uploading to {repo_id}...")
try:
# Upload the entire project directory
upload_folder(
folder_path=".",
repo_id=repo_id,
repo_type=repo_type,
ignore_patterns=ignore_patterns,
token=token,
)
print(f"Successfully uploaded to https://huggingface.co/{repo_id}")
except Exception as e:
print(f"Error uploading: {e}")