Download upload_model.py from Pronoy14744/BartaaT5: direct link, hf CLI and curl.
- Browser
- Download file 949 Bytes
-
https://huggingface.co/Pronoy14744/BartaaT5/resolve/main/upload_model.py
- Command line
-
hf download hf://Pronoy14744/BartaaT5/upload_model.py
-
curl -L -o upload_model.py https://huggingface.co/Pronoy14744/BartaaT5/resolve/main/upload_model.py
949 Bytes
| from transformers import AutoModelForSeq2SeqLM, AutoTokenizer | |
| from huggingface_hub import HfApi, login | |
| # Replace with your Hugging Face username | |
| HF_USERNAME = "Pronoy14744" # Update with your actual username | |
| MODEL_NAME = "BartaaT5" | |
| REPO_ID = f"{HF_USERNAME}/{MODEL_NAME}" | |
| # Authenticate with Hugging Face | |
| login() | |
| # Define model path | |
| model_dir = "BartaaT5" # Update with the correct path if necessary | |
| # Load the model and tokenizer | |
| model = AutoModelForSeq2SeqLM.from_pretrained(model_dir) | |
| tokenizer = AutoTokenizer.from_pretrained(model_dir) | |
| # Push to Hugging Face Hub | |
| model.push_to_hub(REPO_ID) | |
| tokenizer.push_to_hub(REPO_ID) | |
| # Upload README file | |
| api = HfApi() | |
| api.upload_file( | |
| path_or_fileobj=f"{model_dir}/README.md", # Update if the README path is different | |
| path_in_repo="README.md", # Path where it will be stored in the repo | |
| repo_id=REPO_ID, | |
| ) | |
| print(f"Model uploaded successfully to: https://huggingface.co/{REPO_ID}") | |