harpoon-1-2 / upload_to_hf.py
christiankhoury05's picture
HarpoonNet 1.2 - ConvNeXt-Small Architecture (~50M params) - Fixed Model Upload
cfe3297 verified
#!/usr/bin/env python3
"""
Script to upload HarpoonNet 1.2 model to Hugging Face Hub
"""
import os
from huggingface_hub import HfApi, login
import getpass
def upload_model():
"""Upload the model to Hugging Face Hub"""
# Get token from user
print("πŸ” Please enter your Hugging Face token:")
print(" (Get it from: https://huggingface.co/settings/tokens)")
token = getpass.getpass("Token: ")
# Login to Hugging Face
try:
login(token=token)
print("βœ… Successfully logged in to Hugging Face!")
except Exception as e:
print(f"❌ Login failed: {e}")
return False
# Initialize the API
api = HfApi()
# Repository details
repo_id = "christiankhoury05/harpoon-1-2"
try:
print(f"πŸš€ Uploading model to {repo_id}...")
# Upload all files in the current directory
api.upload_folder(
folder_path=".",
repo_id=repo_id,
repo_type="model",
commit_message="HarpoonNet 1.2 - ConvNeXt-Small Architecture (~50M params) - Fixed Model Upload"
)
print("βœ… Model uploaded successfully!")
print(f"🌐 View your model at: https://huggingface.co/{repo_id}")
return True
except Exception as e:
print(f"❌ Upload failed: {e}")
return False
if __name__ == "__main__":
print("🎯 HarpoonNet 1.2 - Hugging Face Upload Script")
print("=" * 50)
# Check if we're in the right directory
if not os.path.exists("pytorch_model.pth"):
print("❌ Error: pytorch_model.pth not found in current directory")
print(" Please run this script from the hf_upload directory")
exit(1)
# Upload the model
success = upload_model()
if success:
print("\nπŸŽ‰ Upload completed successfully!")
print("Your HarpoonNet 1.2 model with non-commercial license is now available on Hugging Face!")
print("πŸ“„ Users will see the licensing requirements clearly in the README")
print("πŸ“§ Commercial inquiries will be directed to: [email protected]")
else:
print("\n❌ Upload failed. Please check your token and try again.")