|
|
|
|
|
""" |
|
|
Upload AI Tool Pool Jewelry Vision dataset to Hugging Face Hub |
|
|
""" |
|
|
import os |
|
|
from huggingface_hub import HfApi, create_repo |
|
|
from pathlib import Path |
|
|
|
|
|
def upload_jewelry_dataset(): |
|
|
"""Upload the jewelry vision dataset to Hugging Face Hub""" |
|
|
|
|
|
|
|
|
dataset_name = "ai-tool-pool-jewelry-vision" |
|
|
|
|
|
repo_id = f"bzcasper/{dataset_name}" |
|
|
|
|
|
|
|
|
dataset_path = Path(__file__).parent |
|
|
|
|
|
print(f"Dataset path: {dataset_path}") |
|
|
print(f"Repository ID: {repo_id}") |
|
|
|
|
|
|
|
|
api = HfApi() |
|
|
|
|
|
try: |
|
|
|
|
|
print("Creating repository on Hugging Face Hub...") |
|
|
create_repo( |
|
|
repo_id=repo_id, |
|
|
repo_type="dataset", |
|
|
exist_ok=True, |
|
|
private=False |
|
|
) |
|
|
print(f"✅ Repository created: https://huggingface.co/datasets/{repo_id}") |
|
|
|
|
|
|
|
|
print("Uploading dataset files...") |
|
|
|
|
|
|
|
|
api.upload_file( |
|
|
path_or_fileobj=dataset_path / "README.md", |
|
|
path_in_repo="README.md", |
|
|
repo_id=repo_id, |
|
|
repo_type="dataset", |
|
|
) |
|
|
print("✅ README.md uploaded") |
|
|
|
|
|
|
|
|
for split_dir in ["train", "test", "valid"]: |
|
|
split_path = dataset_path / split_dir |
|
|
if split_path.exists(): |
|
|
print(f"Uploading {split_dir} split...") |
|
|
api.upload_folder( |
|
|
folder_path=split_path, |
|
|
path_in_repo=split_dir, |
|
|
repo_id=repo_id, |
|
|
repo_type="dataset", |
|
|
ignore_patterns=["*.txt"], |
|
|
) |
|
|
print(f"✅ {split_dir} split uploaded") |
|
|
|
|
|
|
|
|
for readme_file in ["README.dataset.txt", "README.roboflow.txt"]: |
|
|
readme_path = dataset_path / readme_file |
|
|
if readme_path.exists(): |
|
|
api.upload_file( |
|
|
path_or_fileobj=readme_path, |
|
|
path_in_repo=readme_file, |
|
|
repo_id=repo_id, |
|
|
repo_type="dataset", |
|
|
) |
|
|
print(f"✅ {readme_file} uploaded") |
|
|
|
|
|
print(f"\n🎉 Dataset successfully uploaded!") |
|
|
print(f"📋 Dataset URL: https://huggingface.co/datasets/{repo_id}") |
|
|
print(f"📁 Total files uploaded from train, test, and valid splits") |
|
|
|
|
|
except Exception as e: |
|
|
print(f"❌ Error uploading dataset: {str(e)}") |
|
|
print("\nMake sure you:") |
|
|
print("1. Are logged in: huggingface-cli login") |
|
|
print("2. Have updated the repo_id with your username") |
|
|
print("3. Have write permissions to the repository") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
upload_jewelry_dataset() |