import gradio as gr import subprocess import os def run_diagnostic(): try: # Run the diagnostic script and capture output result = subprocess.run( ["python3", "debug_model_loading.py"], capture_output=True, text=True, check=False ) # Combine stdout and stderr output = result.stdout + "\n" + result.stderr return output except Exception as e: return f"Error running diagnostic: {str(e)}" with gr.Blocks(title="Model Loading Diagnostic") as demo: gr.Markdown("# InternVL2 Model Loading Diagnostic") with gr.Row(): run_btn = gr.Button("Run Diagnostic") output = gr.Textbox(label="Diagnostic Output", lines=30) run_btn.click(fn=run_diagnostic, inputs=[], outputs=output) # Run diagnostic on startup demo.load(fn=run_diagnostic, inputs=[], outputs=output) demo.launch(server_name="0.0.0.0")