|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import argparse, os |
|
|
from huggingface_hub import HfApi, create_repo, upload_file |
|
|
|
|
|
def main(): |
|
|
ap = argparse.ArgumentParser() |
|
|
ap.add_argument("--repo", required=True, help="repo id like user/name") |
|
|
ap.add_argument("--private", action="store_true", help="create as private") |
|
|
args = ap.parse_args() |
|
|
|
|
|
api = HfApi() |
|
|
create_repo(args.repo, repo_type="model", exist_ok=True, private=args.private) |
|
|
|
|
|
base = os.path.dirname(__file__) |
|
|
files = [ |
|
|
"resnet50-corrosion-classifier-v1.pth", |
|
|
"README.md", |
|
|
"model_config.json", |
|
|
"preprocessor_config.json", |
|
|
"requirements.txt", |
|
|
"labels.json" |
|
|
] |
|
|
|
|
|
for f in files: |
|
|
path = os.path.join(base, f) |
|
|
if not os.path.exists(path): |
|
|
raise FileNotFoundError(path) |
|
|
print("Uploading", f) |
|
|
upload_file( |
|
|
path_or_fileobj=path, |
|
|
path_in_repo=f, |
|
|
repo_id=args.repo, |
|
|
repo_type="model" |
|
|
) |
|
|
print("Done. Visit https://huggingface.co/" + args.repo) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |
|
|
|