|
|
|
|
|
""" |
|
|
Script to upload VidChain project to Hugging Face Hub |
|
|
""" |
|
|
|
|
|
import os |
|
|
from huggingface_hub import login, create_repo, HfApi |
|
|
from pathlib import Path |
|
|
|
|
|
def upload_to_huggingface(): |
|
|
|
|
|
print("🔐 Logging in to Hugging Face Hub...") |
|
|
login() |
|
|
|
|
|
|
|
|
repo_id = "simplecloud/VidChain-exercise" |
|
|
repo_type = "dataset" |
|
|
|
|
|
|
|
|
print(f"📦 Creating repository: {repo_id}") |
|
|
try: |
|
|
create_repo( |
|
|
repo_id=repo_id, |
|
|
repo_type=repo_type, |
|
|
exist_ok=True, |
|
|
private=False |
|
|
) |
|
|
print(f"✅ Repository created/verified: {repo_id}") |
|
|
except Exception as e: |
|
|
print(f"⚠️ Repository creation issue: {e}") |
|
|
|
|
|
|
|
|
api = HfApi() |
|
|
|
|
|
|
|
|
print("📤 Uploading project files...") |
|
|
current_dir = Path(".") |
|
|
|
|
|
|
|
|
files_to_upload = [ |
|
|
"upload.py", |
|
|
".gitignore", |
|
|
"asset/", |
|
|
"VTimeLLM/" |
|
|
] |
|
|
|
|
|
|
|
|
for item in files_to_upload: |
|
|
item_path = current_dir / item |
|
|
if item_path.exists(): |
|
|
if item_path.is_file(): |
|
|
print(f"📄 Uploading file: {item}") |
|
|
try: |
|
|
api.upload_file( |
|
|
path_or_fileobj=str(item_path), |
|
|
path_in_repo=item, |
|
|
repo_id=repo_id, |
|
|
repo_type=repo_type |
|
|
) |
|
|
print(f"✅ Successfully uploaded: {item}") |
|
|
except Exception as e: |
|
|
print(f"❌ Failed to upload {item}: {e}") |
|
|
else: |
|
|
print(f"📁 Uploading folder: {item}") |
|
|
try: |
|
|
api.upload_folder( |
|
|
folder_path=str(item_path), |
|
|
path_in_repo=item, |
|
|
repo_id=repo_id, |
|
|
repo_type=repo_type, |
|
|
ignore_patterns=["__pycache__", "*.pyc", ".DS_Store", ".git", ".ipynb"] |
|
|
) |
|
|
print(f"✅ Successfully uploaded: {item}") |
|
|
except Exception as e: |
|
|
print(f"❌ Failed to upload {item}: {e}") |
|
|
else: |
|
|
print(f"⚠️ Skipping {item} - not found") |
|
|
|
|
|
|
|
|
readme_path = current_dir / "README.md" |
|
|
if readme_path.exists(): |
|
|
print("📄 Uploading README.md...") |
|
|
try: |
|
|
api.upload_file( |
|
|
path_or_fileobj=str(readme_path), |
|
|
path_in_repo="README.md", |
|
|
repo_id=repo_id, |
|
|
repo_type=repo_type |
|
|
) |
|
|
print("✅ Successfully uploaded: README.md") |
|
|
except Exception as e: |
|
|
print(f"❌ Failed to upload README.md: {e}") |
|
|
|
|
|
|
|
|
req_path = current_dir / "requirements.txt" |
|
|
if req_path.exists(): |
|
|
print("📄 Uploading requirements.txt...") |
|
|
try: |
|
|
api.upload_file( |
|
|
path_or_fileobj=str(req_path), |
|
|
path_in_repo="requirements.txt", |
|
|
repo_id=repo_id, |
|
|
repo_type=repo_type |
|
|
) |
|
|
print("✅ Successfully uploaded: requirements.txt") |
|
|
except Exception as e: |
|
|
print(f"❌ Failed to upload requirements.txt: {e}") |
|
|
|
|
|
print(f"🎉 Upload completed! Your project is available at: https://huggingface.co/{repo_id}") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
upload_to_huggingface() |