File size: 522 Bytes
f5054aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr

# 定义简单的模型函数
def image_classifier(image, username):
    return {'cat': 0.3, 'dog': 0.7}

# 使用 SimpleCSVLogger 并支持用户名存储
flagging_callback = gr.SimpleCSVLogger()

# 创建 Gradio 接口,增加 username 的输入支持
demo = gr.Interface(
    fn=image_classifier, 
    inputs=["image", "text"],  # 输入包括图像和用户名
    outputs="label", 
    flagging_callback=flagging_callback  # 启用标记功能
)

# 启动界面
demo.launch()