MMB_dataset / upload_with_images.py
Scholarus
New dataset
71f5c5b
"""
Upload MMB dataset with inline images to Hugging Face.
This will authenticate and push the dataset with Image columns.
"""
from pathlib import Path
import sys
# Add the upload script path
sys.path.insert(0, str(Path(__file__).parent.parent / "MMB-Space" / "Datasetviewer"))
from huggingface_hub import login, whoami
from scripts.upload_to_huggingface import main as upload_main
# Check if logged in
try:
user = whoami()
print(f"Logged in as: {user['name']}")
except Exception:
print("Not logged in. Attempting browser login...")
print("If browser doesn't open, get a token from: https://huggingface.co/settings/tokens")
print("Then set environment variable: $env:HF_TOKEN='your_token'")
try:
login() # Will open browser or use HF_TOKEN env var
user = whoami()
print(f"Logged in as: {user['name']}")
except Exception as e:
print(f"Login failed: {e}")
print("\nTo authenticate manually:")
print("1. Get token from: https://huggingface.co/settings/tokens")
print("2. Run: $env:HF_TOKEN='your_token'")
print("3. Then run this script again")
sys.exit(1)
# Run the upload (use Dataset folder - change to "dataset_1k_720p_2" if needed)
csv_path = Path(__file__).parent / "Dataset" / "image_mapping_with_questions.csv"
print(f"\nUploading dataset from: {csv_path}")
# Modify sys.argv to simulate command line args
sys.argv = [
"upload_with_images.py",
str(csv_path),
"--repo-id",
"scholo/MMB_dataset"
]
upload_main()