Created
May 6, 2023 05:08
-
-
Save shahules786/5c8dd668f758efac0402dda5b28c1524 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from huggingface_hub import HfApi | |
import os | |
import argparse | |
api = HfApi() | |
model_files = ["tokenizer.json","special_tokens_map.json","tokenizer_config.json","config.json","pytorch_model.bin"] | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description="") | |
parser.add_argument("--model_url", type=str, help="model url") | |
parser.add_argument("--root_dir", type=str, help="model url") | |
args = parser.parse_args().__dict__ | |
root = args.get("root_dir") | |
files_upload = [os.path.join(root, name) | |
for root, dirs, files in os.walk(root) | |
for name in files | |
if name.split('/')[-1] in model_files ] | |
for file in files_upload: | |
api.upload_file( | |
path_or_fileobj=file, | |
repo_id=args.get("model_url"), | |
repo_type="model", | |
path_in_repo=file.split('/')[-1] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment