vpcom commited on
Commit
f72f753
·
1 Parent(s): ee52aeb

feat: download a repo

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -1,6 +1,20 @@
1
  import gradio as gr
 
 
 
 
 
2
 
3
  def func(hf_token, repo, revision, target_repo):
 
 
 
 
 
 
 
 
 
4
  return f"Using {hf_token}, the content of {repo}/{revision} has been copied to {target_repo}!"
5
 
6
  iface = gr.Interface(fn=func, inputs=["text","text","text"], outputs="text")
 
1
  import gradio as gr
2
+ from huggingface_hub import HfApi
3
+ import os
4
+
5
+ hf_api = HfApi()
6
+ CURRENT_MODEL_PATH = "./current_model"
7
 
8
  def func(hf_token, repo, revision, target_repo):
9
+ print('download the desired model locally ...')
10
+ hf_api.hf_hub_download(
11
+ repo_id=repo,
12
+ revision=revision,
13
+ token=hf_token,
14
+ local_dir=CURRENT_MODEL_PATH,
15
+ )
16
+ os.listdir(CURRENT_MODEL_PATH)
17
+
18
  return f"Using {hf_token}, the content of {repo}/{revision} has been copied to {target_repo}!"
19
 
20
  iface = gr.Interface(fn=func, inputs=["text","text","text"], outputs="text")