#!/usr/bin/env python3 """ 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 configuration dataset_name = "ai-tool-pool-jewelry-vision" # Change this to your desired repo name # Replace YOUR_USERNAME with your HF username repo_id = f"bzcasper/{dataset_name}" # Get current directory (dataset root) dataset_path = Path(__file__).parent print(f"Dataset path: {dataset_path}") print(f"Repository ID: {repo_id}") # Initialize HF API api = HfApi() try: # Create repository on Hugging Face Hub print("Creating repository on Hugging Face Hub...") create_repo( repo_id=repo_id, repo_type="dataset", exist_ok=True, private=False # Set to True if you want private repo ) print(f"āœ… Repository created: https://huggingface.co/datasets/{repo_id}") # Upload all files to the repository print("Uploading dataset files...") # Upload the README first 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") # Upload dataset files by folder 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"], # Skip tokenization files ) print(f"āœ… {split_dir} split uploaded") # Upload original README files for reference 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()