Jin Zhu commited on
Commit
7ddbb03
·
1 Parent(s): 8b24479

Update app.py

Browse files
Files changed (1) hide show
  1. src/app.py +24 -58
src/app.py CHANGED
@@ -36,19 +36,6 @@ import streamlit as st
36
  from FineTune.model import ComputeStat
37
  import time
38
 
39
- st.markdown(
40
- """
41
- <style>
42
- /* 控制 Streamlit columns 间距 */
43
- div[data-testid="column"] {
44
- padding-left: 3.0rem;
45
- padding-right: 3.0rem;
46
- }
47
- </style>
48
- """,
49
- unsafe_allow_html=True
50
- )
51
-
52
  st.markdown(
53
  """
54
  <style>
@@ -112,39 +99,6 @@ st.markdown(
112
  unsafe_allow_html=True
113
  )
114
 
115
- st.markdown(
116
- """
117
- <style>
118
- /* Significance slider – light purple (academic) */
119
-
120
- /* Slider track (inactive) */
121
- div[data-testid="stSlider"] > div > div > div > div {
122
- background-color: #ebe7f2;
123
- }
124
-
125
- /* Slider active range */
126
- div[data-testid="stSlider"] div[role="slider"] {
127
- background-color: #bebada !important;
128
- border-color: #bebada !important;
129
- }
130
-
131
- /* Slider thumb */
132
- div[data-testid="stSlider"] div[role="slider"]::before {
133
- background-color: #bc80bd;
134
- box-shadow: 0 0 0 1px rgba(188,128,189,0.4);
135
- }
136
-
137
- /* α value text */
138
- div[data-testid="stSlider"] span {
139
- color: #bc80bd;
140
- font-weight: 500;
141
- }
142
- </style>
143
- """,
144
- unsafe_allow_html=True
145
- )
146
-
147
-
148
  # -----------------
149
  # Page Configuration
150
  # -----------------
@@ -296,20 +250,18 @@ if not model_loaded:
296
  # --- Two columns: Input text & button | Result displays ---
297
  text_input = st.text_area(
298
  label="",
299
- placeholder="Paste your text to be detected here",
300
- help="Typically, providing text with a longer content would get a more reliable result.",
301
- height=200,
302
  )
303
 
304
  subcol11, subcol12, subcol13 = st.columns((1, 1, 1))
305
 
306
  selected_domain = subcol11.selectbox(
307
- label="⚙️ Domain",
308
  options=DOMAINS,
309
  index=0, # Default to General
310
  # label_visibility="collapsed",
311
  # label_visibility="hidden",
312
- help="💡 **Tip:** Select the domain that best matches your text for improving detection accuracy. Default is 'General' that means consider all domains."
313
  )
314
 
315
  detect_clicked = subcol12.button("🔍 Detect", type="primary", use_container_width=True)
@@ -321,17 +273,16 @@ selected_level = subcol13.slider(
321
  value=0.05,
322
  step=0.005,
323
  # label_visibility="collapsed",
324
- help="💡 **Tip:** Select the significance level for the detection test."
325
  )
326
 
327
- col2, col3 = st.columns((1, 1))
328
  with col2:
329
  statistics_ph = st.empty()
330
  statistics_ph.text_input(
331
  label="Statistic",
332
  value="",
 
333
  disabled=True,
334
- help="Statistic will appear here after clicking the Detect button.",
335
  )
336
 
337
  with col3:
@@ -339,8 +290,17 @@ with col3:
339
  pvalue_ph.text_input(
340
  label="p-value",
341
  value="",
 
 
 
 
 
 
 
 
 
 
342
  disabled=True,
343
- help="p-value will appear here after clicking the Detect button.",
344
  )
345
 
346
  # -----------------
@@ -402,12 +362,18 @@ if detect_clicked:
402
  help="p-value will appear here after clicking Detect.",
403
  )
404
 
 
 
 
 
 
 
 
405
  st.info(
406
  """
407
  **📊 p-value:**
408
  - **Lower p-value** (closer to 0) indicates text is **more likely AI-generated**
409
  - **Higher p-value** (closer to 1) indicates text is **more likely human-written**
410
- - Generally, p-value < 0.05 suggests the text may be LLM-generated
411
  """,
412
  icon="💡"
413
  )
@@ -508,14 +474,14 @@ st.markdown(
508
  background-color: white;
509
  color: gray;
510
  text-align: center;
511
- padding: 10px;
512
  border-top: 1px solid #e0e0e0;
513
  z-index: 999;
514
  }
515
 
516
  /* Add padding to main content to prevent overlap with fixed footer */
517
  .main .block-container {
518
- padding-bottom: 60px;
519
  }
520
  </style>
521
  <div class='footer'>
 
36
  from FineTune.model import ComputeStat
37
  import time
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  st.markdown(
40
  """
41
  <style>
 
99
  unsafe_allow_html=True
100
  )
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  # -----------------
103
  # Page Configuration
104
  # -----------------
 
250
  # --- Two columns: Input text & button | Result displays ---
251
  text_input = st.text_area(
252
  label="",
253
+ placeholder="Paste your text to be detected here. Typically, providing text with a longer content would get a more reliable result.",
254
+ height=240,
 
255
  )
256
 
257
  subcol11, subcol12, subcol13 = st.columns((1, 1, 1))
258
 
259
  selected_domain = subcol11.selectbox(
260
+ label="💡 Domain that matches your text",
261
  options=DOMAINS,
262
  index=0, # Default to General
263
  # label_visibility="collapsed",
264
  # label_visibility="hidden",
 
265
  )
266
 
267
  detect_clicked = subcol12.button("🔍 Detect", type="primary", use_container_width=True)
 
273
  value=0.05,
274
  step=0.005,
275
  # label_visibility="collapsed",
 
276
  )
277
 
278
+ col2, col3, col4 = st.columns((1, 1, 2))
279
  with col2:
280
  statistics_ph = st.empty()
281
  statistics_ph.text_input(
282
  label="Statistic",
283
  value="",
284
+ placeholder="",
285
  disabled=True,
 
286
  )
287
 
288
  with col3:
 
290
  pvalue_ph.text_input(
291
  label="p-value",
292
  value="",
293
+ placeholder="",
294
+ disabled=True,
295
+ )
296
+
297
+ with col4:
298
+ conclusion_ph = st.empty()
299
+ conclusion_ph.text_input(
300
+ label="Conclusion",
301
+ value="",
302
+ placeholder="",
303
  disabled=True,
 
304
  )
305
 
306
  # -----------------
 
362
  help="p-value will appear here after clicking Detect.",
363
  )
364
 
365
+ conclusion_ph.text_input(
366
+ label="Conclusion",
367
+ value="Reject H0: Text is likely LLM-generated." if p_value < selected_level else "Fail to Reject H0: Text is likely human-written.",
368
+ disabled=True,
369
+ help="Conclusion will appear here after clicking Detect.",
370
+ )
371
+
372
  st.info(
373
  """
374
  **📊 p-value:**
375
  - **Lower p-value** (closer to 0) indicates text is **more likely AI-generated**
376
  - **Higher p-value** (closer to 1) indicates text is **more likely human-written**
 
377
  """,
378
  icon="💡"
379
  )
 
474
  background-color: white;
475
  color: gray;
476
  text-align: center;
477
+ padding: 1px;
478
  border-top: 1px solid #e0e0e0;
479
  z-index: 999;
480
  }
481
 
482
  /* Add padding to main content to prevent overlap with fixed footer */
483
  .main .block-container {
484
+ padding-bottom: 1px;
485
  }
486
  </style>
487
  <div class='footer'>