import gradio as gr from huggingface_hub import HfApi import os hf_api = HfApi() CURRENT_MODEL_PATH = "./current_model" HF_TOKEN = os.environ.get("HF_TOKEN", None) REPO = os.getenv("REPO") REVISION = os.getenv("REVISION") def func(hf_token, repo, revision, target_repo): print('download the desired model locally ...') hf_api.snapshot_download( repo_id=repo if len(repo)>0 else REPO, revision=revision if len(revision)>0 else REVISION, token=hf_token if len(hf_token)>0 else HF_TOKEN, local_dir=CURRENT_MODEL_PATH, ) print(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()