sundaram07 commited on
Commit
fcb88c5
Β·
verified Β·
1 Parent(s): 375ed47

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. 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
- st.session_state.analysis_done = True
83
- st.session_state.analysis_results = analysis_results
84
- st.session_state.ai_percentage = ai_percentage
85
-
86
- # πŸ“€ Show results
87
- if st.session_state.get("analysis_done", False):
88
- st.subheader("πŸ” Sentence-level Analysis")
89
- for i, (sentence, prob, is_ai) in enumerate(st.session_state.analysis_results, start=1):
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}%**")