reach-vb HF staff commited on
Commit
ee1187d
1 Parent(s): 173d502
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -36,8 +36,8 @@ def clear_hf_cache_space():
36
  scan.delete_revisions(*to_delete).execute()
37
  print("Cache has been cleared")
38
 
39
- def upload_to_hub(path, upload_repo, hf_path, token):
40
- card = ModelCard.load(hf_path)
41
  card.data.tags = ["mlx"] if card.data.tags is None else card.data.tags + ["mlx"]
42
  card.data.base_model = hf_path
43
  card.text = dedent(
@@ -73,7 +73,7 @@ def upload_to_hub(path, upload_repo, hf_path, token):
73
 
74
  logging.set_verbosity_info()
75
 
76
- api = HfApi(token=token)
77
  api.create_repo(repo_id=upload_repo, exist_ok=True)
78
  api.upload_folder(
79
  folder_path=path,
@@ -81,6 +81,7 @@ def upload_to_hub(path, upload_repo, hf_path, token):
81
  repo_type="model",
82
  multi_commits=True,
83
  multi_commits_verbose=True,
 
84
  )
85
  print(f"Upload successful, go to https://huggingface.co/{upload_repo} for details.")
86
 
@@ -98,7 +99,7 @@ def process_model(model_id, q_method, oauth_token: gr.OAuthToken | None):
98
  mlx_path = os.path.join(tmpdir, "mlx")
99
  convert(model_id, mlx_path=mlx_path, quantize=True, q_bits=QUANT_PARAMS[q_method])
100
  print("Conversion done")
101
- upload_to_hub(path=mlx_path, upload_repo=upload_repo, hf_path=model_id, token=oauth_token.token)
102
  print("Upload done")
103
  return (
104
  f'Find your repo <a href="https://hf.co/{upload_repo}" target="_blank" style="text-decoration:underline">here</a>',
 
36
  scan.delete_revisions(*to_delete).execute()
37
  print("Cache has been cleared")
38
 
39
+ def upload_to_hub(path, upload_repo, hf_path, oauth_token):
40
+ card = ModelCard.load(hf_path, token=oauth_token.token)
41
  card.data.tags = ["mlx"] if card.data.tags is None else card.data.tags + ["mlx"]
42
  card.data.base_model = hf_path
43
  card.text = dedent(
 
73
 
74
  logging.set_verbosity_info()
75
 
76
+ api = HfApi(token=oauth_token.token)
77
  api.create_repo(repo_id=upload_repo, exist_ok=True)
78
  api.upload_folder(
79
  folder_path=path,
 
81
  repo_type="model",
82
  multi_commits=True,
83
  multi_commits_verbose=True,
84
+ token=oauth_token.token
85
  )
86
  print(f"Upload successful, go to https://huggingface.co/{upload_repo} for details.")
87
 
 
99
  mlx_path = os.path.join(tmpdir, "mlx")
100
  convert(model_id, mlx_path=mlx_path, quantize=True, q_bits=QUANT_PARAMS[q_method])
101
  print("Conversion done")
102
+ upload_to_hub(path=mlx_path, upload_repo=upload_repo, hf_path=model_id, token=oauth_token)
103
  print("Upload done")
104
  return (
105
  f'Find your repo <a href="https://hf.co/{upload_repo}" target="_blank" style="text-decoration:underline">here</a>',