Download push_to_hub.py from zeechimp/hv-reader: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/zeechimp/hv-reader/resolve/main/push_to_hub.py
- Command line
-
hf download hf://zeechimp/hv-reader/push_to_hub.py
-
curl -L -o push_to_hub.py https://huggingface.co/zeechimp/hv-reader/resolve/main/push_to_hub.py
1.1 kB
| """Push hv-reader to the Hugging Face Hub.""" | |
| import os | |
| from huggingface_hub import HfApi, create_repo | |
| from hv_reader import HVReader | |
| REPO_ID = "zeechimp/hv-reader" | |
| def main() -> None: | |
| api = HfApi() | |
| create_repo(REPO_ID, repo_type="model", exist_ok=True) | |
| model = HVReader() | |
| model.save_pretrained("./hv_reader_model") | |
| api.upload_folder( | |
| folder_path="./hv_reader_model", | |
| repo_id=REPO_ID, | |
| path_in_repo=".", | |
| commit_message="Upload hv-reader config", | |
| ) | |
| for fname in [ | |
| "hv_reader.py", "app.py", "example.py", "push_to_hub.py", | |
| "README.md", "requirements.txt", "LICENSE", ".gitattributes", | |
| ]: | |
| if not os.path.exists(fname): | |
| print(f" skip (missing): {fname}") | |
| continue | |
| api.upload_file( | |
| path_or_fileobj=fname, | |
| path_in_repo=fname, | |
| repo_id=REPO_ID, | |
| commit_message=f"Upload {fname}", | |
| ) | |
| print(f" uploaded: {fname}") | |
| print() | |
| print(f"pushed to https://huggingface.co/{REPO_ID}") | |
| if __name__ == "__main__": | |
| main() |