CoolFace
Apppublic

robinjhuang/custom-diffusion

sourceHugging Faceupdated 4y agoView on Hugging Face
0likes
uploader.py21 linesDownload Raw Back to root
1import gradio as gr2from huggingface_hub import HfApi3 4 5def upload(model_name: str, hf_token: str) -> None:6    api = HfApi(token=hf_token)7    user_name = api.whoami()['name']8    model_id = f'{user_name}/{model_name}'9    try:10        api.create_repo(model_id, repo_type='model', private=True)11        api.upload_folder(repo_id=model_id,12                          folder_path='results',13                          path_in_repo='results',14                          repo_type='model')15        url = f'https://huggingface.co/{model_id}'16        message = f'Your model was successfully uploaded to [{url}]({url}).'17    except Exception as e:18        message = str(e)19 20    return gr.update(value=message, visible=True)21