File size: 775 Bytes
1ca0af5 ad238e8 e936e9a bd0a6b5 e936e9a bd0a6b5 e936e9a bd0a6b5 e936e9a bd0a6b5 e936e9a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from transformers import pipeline
import streamlit as st
pipe1 = pipeline("text-classification", model="Emma0123/fine_tuned_model")
pipe2 = pipeline("text-classification", model="jonas/roberta-base-finetuned-sdg")
# 获取用户输入的文本
input_text = input("Please enter the text: ")
# 使用第一个模型进行预测
result1 = pipe1(input_text)
# 判断第一个模型的输出结果
if result1[0]['label'] == 'LABEL_1': # 根据您的模型实际返回的标签进行修改
# 如果输出结果为1(或者对应的标签),将输入文本传递给第二个模型
result2 = pipe2(input_text)
print(result2)
else:
# 如果输出结果为0(或者对应的标签),打印提示信息
print("This content is unrelated to Environment.")
|