#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Script to upload the InternVL2 files to Hugging Face Spaces """ import os import sys import getpass from huggingface_hub import HfApi, create_repo, upload_folder # Default repository name DEFAULT_REPO = "mknolan/cursor_slides_internvl2" def main(): """Main function to upload files to Hugging Face Spaces""" # Get Hugging Face token with WRITE access token = getpass.getpass("Enter your Hugging Face token (with WRITE access): ") # Get repository name repo_name = input("Enter repository name (default: {}): ".format(DEFAULT_REPO)) or DEFAULT_REPO print("Uploading to Space: {}".format(repo_name)) # Initialize Hugging Face API api = HfApi(token=token) try: # Try to get the repository, create if it doesn't exist try: repo = api.repo_info(repo_id=repo_name, repo_type="space") print("Repo {} ready".format(repo_name)) except Exception: print("Creating new Space: {}".format(repo_name)) create_repo( repo_id=repo_name, token=token, repo_type="space", space_sdk="gradio", private=False ) # Upload the entire folder at once using upload_folder print("Uploading files to Hugging Face Space...") upload_folder( folder_path=".", # Current directory repo_id=repo_name, repo_type="space", ignore_patterns=[ ".git*", "*__pycache__*", "*.pyc", ".DS_Store", "*.ipynb_checkpoints*", "venv", ".env" ], commit_message="Upload InternVL2 implementation", token=token ) print("Upload completed!") print("Check your Space at: https://huggingface.co/spaces/{}".format(repo_name)) except Exception as e: print("Error: {}".format(e)) return 1 return 0 if __name__ == "__main__": sys.exit(main())