eljanmahammadli commited on
Commit
3c8629c
1 Parent(s): d9f10e9

integrated gradient highlighter plot under text

Browse files
Files changed (2) hide show
  1. app.py +6 -2
  2. highlighter.py +19 -0
app.py CHANGED
@@ -176,7 +176,7 @@ with gr.Blocks() as demo:
176
  with gr.Row():
177
  with gr.Column():
178
  QLabel = gr.Label(label="Humanized")
179
-
180
  with gr.Row():
181
  quillbot_highlighter_output = gr.HTML(label="Humanized Highlighter")
182
 
@@ -312,4 +312,8 @@ with gr.Blocks() as demo:
312
 
313
 
314
  if __name__ == "__main__":
315
- demo.launch(share=True, auth=("polygraf-admin", "test@aisd"))
 
 
 
 
 
176
  with gr.Row():
177
  with gr.Column():
178
  QLabel = gr.Label(label="Humanized")
179
+
180
  with gr.Row():
181
  quillbot_highlighter_output = gr.HTML(label="Humanized Highlighter")
182
 
 
312
 
313
 
314
  if __name__ == "__main__":
315
+ demo.launch(
316
+ share=True,
317
+ auth=("polygraf-admin", "test@aisd"),
318
+ allowed_paths=[".", "images"],
319
+ )
highlighter.py CHANGED
@@ -64,4 +64,23 @@ def analyze_and_highlight(text, model_type):
64
  )
65
  highlighted_text += highlighted_sentence
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  return highlighted_text
 
64
  )
65
  highlighted_text += highlighted_sentence
66
 
67
+ if model_type == "bc":
68
+ gradient_labels = ["HUMAN", "AI"]
69
+ elif model_type == "quillbot":
70
+ gradient_labels = ["ORIGINAL", "HUMANIZED"]
71
+ else:
72
+ raise ValueError(f"Invalid model type: {model_type}")
73
+
74
+ highlighted_text = (
75
+ "<div>"
76
+ + highlighted_text
77
+ + "<div style='margin-top: 20px; text-align: center;'>"
78
+ + "<div style='position: relative; display: inline-block; width: 60%; height: 20px; background: linear-gradient(to right, #00FF00, #FFFFFF, #FF0000); font-family: \"Segoe UI\", Tahoma, Geneva, Verdana, sans-serif; font-size: 10px; font-weight: 600; color: #222; border-radius: 10px; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1);'>"
79
+ + f"<span style='position: absolute; left: 5px; top: 50%; transform: translateY(-50%); color: #000; font-weight: 600;'>{gradient_labels[0]}</span>"
80
+ + f"<span style='position: absolute; right: 5px; top: 50%; transform: translateY(-50%); color: #000; font-weight: 600;'>{gradient_labels[1]}</span>"
81
+ + "</div>"
82
+ + "</div>"
83
+ + "</div>"
84
+ )
85
+
86
  return highlighted_text