import gradio as gr from transformers import DepthAnythingForDepthEstimation # 加载模型 model = DepthAnythingForDepthEstimation.from_pretrained("depth-anything/Depth-Anything-V2-Small-hf") backbone = model.backbone config = backbone.config # 定义获取主干信息的函数 def get_backbone_info(): info = f"主干: {backbone.__class__.__name__}\n" info += f"隐藏层大小: {config.hidden_size}\n" info += f"层数: {config.num_hidden_layers}\n" info += f"注意力头数: {config.num_attention_heads}\n" info += f"补丁大小: {config.patch_size}\n" return info # 创建 Gradio 接口 demo = gr.Interface(fn=get_backbone_info, inputs=[], outputs="text") demo.launch()