Spaces:
Runtime error
Runtime error
Merge branch 'main' into demo
Browse files- app.py +1 -1
- 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 |
|
|
|
|
| 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 |
|
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
|