Rae / deploy.py
taiy0's picture
Upload folder using huggingface_hub
5d8396d verified
Raw History Blame Contribute Delete
728 Bytes
from transformers import GPT2LMHeadModel, GPT2Tokenizer
from huggingface_hub import HfApi, login
# Log in programmatically (Optional: If you didn’t use `huggingface-cli login`)
login(token="token") # Replace with your actual token
# Load your fine-tuned model and tokenizer
model_path = "./gpt2_finetuned"
model = GPT2LMHeadModel.from_pretrained(model_path)
tokenizer = GPT2Tokenizer.from_pretrained(model_path)
# Define your Hugging Face model repository name
repo_id = "taiy0/Rae" # Replace with your actual repo name
# Push model and tokenizer to Hugging Face
model.push_to_hub(repo_id)
tokenizer.push_to_hub(repo_id)
print(f"✅ Model uploaded to Hugging Face: https://huggingface.co/{repo_id}")