echarlaix HF staff commited on
Commit
3d43c74
1 Parent(s): 6611a8f

enable export of private and gated repo

Browse files
Files changed (2) hide show
  1. app.py +3 -1
  2. requirements.txt +7 -4
app.py CHANGED
@@ -41,7 +41,9 @@ def export(model_id: str, private_repo: bool, oauth_token: gr.OAuthToken):
41
  model_name = model_id.split("/")[-1]
42
  username = whoami(oauth_token.token)["name"]
43
  new_repo_id = f"{username}/{model_name}-openvino"
 
44
  task = TasksManager.infer_task_from_model(model_id)
 
45
  if task not in _HEAD_TO_AUTOMODELS:
46
  raise ValueError(
47
  f"The task '{task}' is not supported, only {_HEAD_TO_AUTOMODELS.keys()} tasks are supported"
@@ -67,7 +69,7 @@ def export(model_id: str, private_repo: bool, oauth_token: gr.OAuthToken):
67
  os.makedirs(folder)
68
  try:
69
  api.snapshot_download(repo_id=model_id, local_dir=folder, allow_patterns=["*.json"])
70
- ov_model = eval(auto_model_class).from_pretrained(model_id, export=True, cache_dir=folder)
71
  ov_model.save_pretrained(folder)
72
  new_repo_url = api.create_repo(repo_id=new_repo_id, exist_ok=True, private=private_repo)
73
  new_repo_id = new_repo_url.repo_id
 
41
  model_name = model_id.split("/")[-1]
42
  username = whoami(oauth_token.token)["name"]
43
  new_repo_id = f"{username}/{model_name}-openvino"
44
+ # task = TasksManager.infer_task_from_model(model_id, token=oauth_token.token)
45
  task = TasksManager.infer_task_from_model(model_id)
46
+
47
  if task not in _HEAD_TO_AUTOMODELS:
48
  raise ValueError(
49
  f"The task '{task}' is not supported, only {_HEAD_TO_AUTOMODELS.keys()} tasks are supported"
 
69
  os.makedirs(folder)
70
  try:
71
  api.snapshot_download(repo_id=model_id, local_dir=folder, allow_patterns=["*.json"])
72
+ ov_model = eval(auto_model_class).from_pretrained(model_id, export=True, cache_dir=folder, token=oauth_token.token)
73
  ov_model.save_pretrained(folder)
74
  new_repo_url = api.create_repo(repo_id=new_repo_id, exist_ok=True, private=private_repo)
75
  new_repo_id = new_repo_url.repo_id
requirements.txt CHANGED
@@ -1,6 +1,9 @@
1
  huggingface_hub==0.23.4
2
- transformers==4.42.4
3
- optimum[diffusers]==1.21.2
4
- optimum-intel[openvino]==1.18.1
5
  gradio[oauth]>=4.37.2
6
- gradio_huggingfacehub_search==0.0.6
 
 
 
 
 
 
 
1
  huggingface_hub==0.23.4
 
 
 
2
  gradio[oauth]>=4.37.2
3
+ gradio_huggingfacehub_search==0.0.6
4
+ transformers==4.42.4
5
+ diffusers==0.29.1
6
+ optimum==1.21.2
7
+ optimum-intel==1.18.1
8
+ openvino
9
+ nncf