Spaces:
Sleeping
Sleeping
File size: 1,615 Bytes
35429d6 ae1d265 756c357 e2d440e 35429d6 ae1d265 e2d440e 756c357 35429d6 e2d440e 35429d6 e2d440e 35429d6 e2d440e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import gradio as gr
import logging
from optimum.neuron import utils
import os
# Set up logging
logging.basicConfig(level=logging.INFO)
def get_model_info(model_id):
"""Retrieve configuration details for a specific model."""
if not model_id:
return "No model selected"
config_list = utils.get_hub_cached_entries(model_id=model_id, mode="inference")
return config_list
def get_model_list():
"""Retrieve list of cached models."""
return utils.get_hub_cached_models(mode="inference")
def create_model_list_interface():
"""Create a Gradio interface with model list as clickable buttons."""
# Get the model list and sort alphabetically by full model ID
models = sorted(get_model_list(), key=lambda x: (x[1] + x[2]).lower())
print(models)
# Prepare model IDs for buttons
model_ids = [f"{org}/{name}" for (arch, org, name) in models]
# Create the interface
with gr.Blocks() as iface:
with gr.Tab("Model List"):
# Buttons
with gr.Row():
buttons = gr.Radio(
choices=model_ids,
label="Select a Model"
)
# Output for model details
output = gr.Textbox(label="Model Configuration", lines=20)
# Connect model selection to output
buttons.change(
fn=get_model_info,
inputs=buttons,
outputs=output
)
return iface
# Launch the interface
if __name__ == "__main__":
iface = create_model_list_interface()
iface.launch() |