DEPLOY / app.py
vpcom's picture
fix: don't print the secret vars
40b1a45
raw
history blame
954 Bytes
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")
TARGET = os.getenv("TARGET")
def func(hf_token, repo, revision, target_repo):
hf_token = hf_token if hf_token is None else HF_TOKEN
repo = repo if repo is None else REPO
revision = revision if revision is None else REVISION
target_repo = target_repo if target_repo is None else TARGET
print('download the desired model locally ...')
hf_api.snapshot_download(
repo_id=repo,
revision=revision,
token=hf_token,
local_dir=CURRENT_MODEL_PATH,
)
print(os.listdir(CURRENT_MODEL_PATH))
return f"The content of {repo}/{revision} has been copied to {target_repo}!"
iface = gr.Interface(fn=func, inputs=["text","text","text"], outputs="text")
iface.launch()