File size: 715 Bytes
f971083 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
from huggingface_hub import HfApi
def upload(model_name: str, hf_token: str) -> None:
api = HfApi(token=hf_token)
user_name = api.whoami()['name']
model_id = f'{user_name}/{model_name}'
try:
api.create_repo(model_id, repo_type='model', private=True)
api.upload_folder(repo_id=model_id,
folder_path='results',
path_in_repo='results',
repo_type='model')
url = f'https://huggingface.co/{model_id}'
message = f'Your model was successfully uploaded to [{url}]({url}).'
except Exception as e:
message = str(e)
return gr.update(value=message, visible=True)
|