# 开始开始 安装: ```bash pip install gradio ``` 使用: ```python from gradio import Interface def predict(input_text): # 这里是模型预测的逻辑代码 # 例如,我们可以使用sklearn的逻辑回归模型进行预测 from sklearn.linear_model import LogisticRegression model = LogisticRegression() # 加载或训练模型 return model.predict([input_text])[0] interface = Interface(fn=predict, inputs='text', outputs='int') interface.launch() ``` 这里有 Interface 类,接受三个参数: