DEPLOY / app.py
vpcom's picture
feat: download a repo
f72f753
raw
history blame
601 Bytes
import gradio as gr
from huggingface_hub import HfApi
import os
hf_api = HfApi()
CURRENT_MODEL_PATH = "./current_model"
def func(hf_token, repo, revision, target_repo):
print('download the desired model locally ...')
hf_api.hf_hub_download(
repo_id=repo,
revision=revision,
token=hf_token,
local_dir=CURRENT_MODEL_PATH,
)
os.listdir(CURRENT_MODEL_PATH)
return f"Using {hf_token}, the content of {repo}/{revision} has been copied to {target_repo}!"
iface = gr.Interface(fn=func, inputs=["text","text","text"], outputs="text")
iface.launch()