Spaces:
Sleeping
Sleeping
File size: 1,297 Bytes
e830305 7c8ae88 e830305 7c8ae88 e830305 7c8ae88 e830305 7c8ae88 e830305 7c8ae88 39efac9 7c8ae88 39efac9 7c8ae88 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
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.") |