andstor's picture
Update src/app.py
6640473 verified
raw
history blame contribute delete
No virus
1.33 kB
import gradio as gr
import pandas as pd
from huggingface_hub.utils import HfHubHTTPError
from accelerate.commands.estimate import check_has_model, create_empty_model
from accelerate.utils import calculate_maximum_sizes
from model_utils import get_model
# We need to store them as globals because gradio doesn't have a way for us to pass them in to the button
MODEL = None
def get_results(model_name: str, library: str, access_token: str):
global MODEL
MODEL = get_model(model_name, library, access_token)
data = MODEL.__repr__()
title = f"## Model Representation for '{model_name}'"
return [title, gr.update(visible=True, value=data)]
with gr.Blocks() as demo:
with gr.Column():
out_text = gr.Markdown()
out = gr.Code()
with gr.Row():
inp = gr.Textbox(label="Model Name or URL", value="bert-base-cased")
with gr.Row():
library = gr.Radio(["auto", "transformers", "timm"], label="Library", value="auto")
access_token = gr.Textbox(label="API Token", placeholder="Optional (for gated models)")
with gr.Row():
btn = gr.Button("Show Model Representation")
btn.click(
get_results,
inputs=[inp, library, access_token,],
outputs=[out_text, out],
)
demo.launch()