File size: 668 Bytes
0870e54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b8ba98c
 
 
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 list_models


def list_private_models(oauth_profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToken | None) -> str:
    if oauth_token is None:
        return "Please log in to list private models."
    # List models from author using token
    models = list_models(author=oauth_profile.username, token=oauth_token.token)
    # Return list of private models
    return f"Private models: {', '.join(model.id for model in models if model.private)}"

with gr.Blocks() as demo:
    gr.LoginButton()
    gr.LogoutButton()
    m1 = gr.Markdown()
    demo.load(list_private_models, inputs=None, outputs=m1)

demo.launch()