G35 / app.py
JenniferHJF's picture
Update app.py
7c8ae88 verified
raw
history blame
1.3 kB
import streamlit as st
from agent import classify_emoji_text, available_models
st.set_page_config(page_title="Emoji Offensive Classifier", page_icon="🚨", layout="wide")
st.title("🚨 Offensive Text Detection Agent (with Emoji Translation)")
st.markdown("""
This demo uses a two-step AI agent:
1. Translates emojis & phonetic expressions into clear Chinese using a fine-tuned Qwen model.
2. Classifies the translated sentence for offensiveness using a selectable large language model.
""")
# 左侧:输入区
st.subheader("① Enter a sentence with emoji or homophones:")
example = "你是🐷,好像🤡"
text = st.text_area("Input text:", value=example, height=120)
# 右侧:模型选择区
st.subheader("② Select classification model:")
model_choice = st.selectbox("Choose a classifier", options=list(available_models.keys()))
if st.button("🚦 Analyze"):
with st.spinner("Running multi-stage agent pipeline..."):
translated, label, score = classify_emoji_text(text, model_choice)
st.success("✅ Completed!")
st.markdown(f"### 🔄 Translated sentence:\n```
{translated}
```")
st.markdown(f"### 🎯 Prediction: `{label}`")
st.markdown(f"### 📊 Confidence: `{score:.2%}`")
else:
st.info("Click 'Analyze' to start inference.")