import sys import gradio as gr from huggingface_hub import HfApi, ModelFilter, list_models from subprocess import run #result = run(['script.py'], capture_output=True) #previous_output = result.stdout api = HfApi() models=[ "xai-org/grok-1" ] def load_models(model_in): loaded_model=[] model_details=[] if "/" in model_in: similar_models = api.list_models(search=model_in.split("/")[1],limit=100,cardData=True) else: similar_models = api.list_models(search=model_in,limit=100,cardData=True) for model in similar_models: try: model_path=f'models/{model.id}' this = gr.load(model_path,cache_examples=False).stdout print(this) #loaded_model.append(gr.load(model_path,cache_examples=False).stdout) except Exception as e: loaded_model.append({"MODEL":model.id,"ERROR":e}) try: model_details.append(model) except Exception as ee: model_details.append({"MODEL":model.id,"ERROR":ee}) return loaded_model, model_details with gr.Blocks() as app: with gr.Row(): model_name=gr.Textbox(label="Model", value=models[0], placeholder=models[0]) load_btn=gr.Button("Load") with gr.Row(): models_out=gr.JSON(label="Gradio Details") details=gr.JSON(label="Hub Details") app.load(load_models,model_name,[models_out,details]) load_btn.click(load_models,model_name,[models_out,details]) app.launch()