Download deploy.py from taiy0/Rae: direct link, hf CLI and curl.
- Browser
- Download file 728 Bytes
-
https://huggingface.co/spaces/taiy0/Rae/resolve/main/deploy.py
- Command line
-
hf download hf://spaces/taiy0/Rae/deploy.py
-
curl -L -o deploy.py https://huggingface.co/spaces/taiy0/Rae/resolve/main/deploy.py
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}") | |