Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +11 -19
src/streamlit_app.py
CHANGED
@@ -63,32 +63,24 @@ st.markdown("This app detects the percentage of **AI-generated content** using s
|
|
63 |
# π Text input
|
64 |
user_input = st.text_area("π Paste your text below to check for AI-generated sentences:", height=300)
|
65 |
|
|
|
|
|
|
|
66 |
# π Analyze button logic
|
67 |
if st.button("π Analyze"):
|
68 |
-
# Clear previous session results
|
69 |
-
st.session_state.analysis_done = False
|
70 |
-
st.session_state.analysis_results = None
|
71 |
-
st.session_state.ai_percentage = None
|
72 |
-
|
73 |
if not user_input.strip():
|
74 |
st.warning("β οΈ Please enter some text.")
|
75 |
else:
|
76 |
-
# Perform analysis
|
77 |
ai_percentage, analysis_results = predict_ai_generated_percentage(user_input)
|
78 |
|
79 |
if len(analysis_results) == 0:
|
80 |
st.warning("β οΈ Not enough valid sentences to analyze.")
|
81 |
else:
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
label = "π’ Human" if not is_ai else "π΄ AI"
|
91 |
-
st.markdown(f"**{i}.** _{sentence}_\n\n β {label}")
|
92 |
-
|
93 |
-
st.subheader("π Final Result")
|
94 |
-
st.success(f"Estimated **AI-generated content**: **{st.session_state.ai_percentage:.2f}%**")
|
|
|
63 |
# π Text input
|
64 |
user_input = st.text_area("π Paste your text below to check for AI-generated sentences:", height=300)
|
65 |
|
66 |
+
# π€ Output placeholder (to clear previous results)
|
67 |
+
output_container = st.empty()
|
68 |
+
|
69 |
# π Analyze button logic
|
70 |
if st.button("π Analyze"):
|
|
|
|
|
|
|
|
|
|
|
71 |
if not user_input.strip():
|
72 |
st.warning("β οΈ Please enter some text.")
|
73 |
else:
|
|
|
74 |
ai_percentage, analysis_results = predict_ai_generated_percentage(user_input)
|
75 |
|
76 |
if len(analysis_results) == 0:
|
77 |
st.warning("β οΈ Not enough valid sentences to analyze.")
|
78 |
else:
|
79 |
+
with output_container.container():
|
80 |
+
st.subheader("π Sentence-level Analysis")
|
81 |
+
for i, (sentence, prob, is_ai) in enumerate(analysis_results, start=1):
|
82 |
+
label = "π’ Human" if not is_ai else "π΄ AI"
|
83 |
+
st.markdown(f"**{i}.** _{sentence}_\n\n β {label}")
|
84 |
+
|
85 |
+
st.subheader("π Final Result")
|
86 |
+
st.success(f"Estimated **AI-generated content**: **{ai_percentage:.2f}%**")
|
|
|
|
|
|
|
|
|
|