Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,7 +55,7 @@ def circular_html(ai_percent):
|
|
| 55 |
</div>
|
| 56 |
</div>
|
| 57 |
"""
|
| 58 |
-
|
| 59 |
# ===== Chunking for Large Input Support =====
|
| 60 |
def chunk_text(text, max_tokens=300):
|
| 61 |
paragraphs = text.split("\n\n")
|
|
@@ -97,6 +97,19 @@ def paraphrase(text):
|
|
| 97 |
for chunk in chunks
|
| 98 |
)
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
# ===== AI Detection and Visualization =====
|
| 101 |
def detect_ai_percent(text):
|
| 102 |
inputs = detector_tokenizer(text, return_tensors="pt", truncation=True, padding=True)
|
|
@@ -134,17 +147,20 @@ with gr.Blocks() as demo:
|
|
| 134 |
input_text = gr.Textbox(lines=12, label="Input Text")
|
| 135 |
load_btn.click(fn=load_file, inputs=file_input, outputs=input_text)
|
| 136 |
|
|
|
|
| 137 |
with gr.Row():
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
|
|
|
|
| 143 |
output_text = gr.Textbox(lines=12, label="Output")
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
|
|
|
| 148 |
|
| 149 |
gr.Markdown("## 🕵️ AI Detection")
|
| 150 |
detect_btn = gr.Button("Detect AI Probability")
|
|
|
|
| 55 |
</div>
|
| 56 |
</div>
|
| 57 |
"""
|
| 58 |
+
|
| 59 |
# ===== Chunking for Large Input Support =====
|
| 60 |
def chunk_text(text, max_tokens=300):
|
| 61 |
paragraphs = text.split("\n\n")
|
|
|
|
| 97 |
for chunk in chunks
|
| 98 |
)
|
| 99 |
|
| 100 |
+
# ===== Apply Enhancements Based on Checkboxes =====
|
| 101 |
+
def apply_selected_enhancements(text, fix, tone, fluency, para):
|
| 102 |
+
result = text
|
| 103 |
+
if fix:
|
| 104 |
+
result = fix_grammar(result)
|
| 105 |
+
if tone:
|
| 106 |
+
result = improve_tone(result)
|
| 107 |
+
if fluency:
|
| 108 |
+
result = improve_fluency(result)
|
| 109 |
+
if para:
|
| 110 |
+
result = paraphrase(result)
|
| 111 |
+
return result
|
| 112 |
+
|
| 113 |
# ===== AI Detection and Visualization =====
|
| 114 |
def detect_ai_percent(text):
|
| 115 |
inputs = detector_tokenizer(text, return_tensors="pt", truncation=True, padding=True)
|
|
|
|
| 147 |
input_text = gr.Textbox(lines=12, label="Input Text")
|
| 148 |
load_btn.click(fn=load_file, inputs=file_input, outputs=input_text)
|
| 149 |
|
| 150 |
+
gr.Markdown("## ✅ Select Enhancements to Apply")
|
| 151 |
with gr.Row():
|
| 152 |
+
check_fix = gr.Checkbox(label="✔️ Fix Grammar")
|
| 153 |
+
check_tone = gr.Checkbox(label="🎯 Improve Tone")
|
| 154 |
+
check_fluency = gr.Checkbox(label="🔄 Improve Fluency")
|
| 155 |
+
check_paraphrase = gr.Checkbox(label="🌀 Paraphrase")
|
| 156 |
|
| 157 |
+
run_selected = gr.Button("🚀 Run Selected Enhancements")
|
| 158 |
output_text = gr.Textbox(lines=12, label="Output")
|
| 159 |
+
run_selected.click(
|
| 160 |
+
fn=apply_selected_enhancements,
|
| 161 |
+
inputs=[input_text, check_fix, check_tone, check_fluency, check_paraphrase],
|
| 162 |
+
outputs=output_text
|
| 163 |
+
)
|
| 164 |
|
| 165 |
gr.Markdown("## 🕵️ AI Detection")
|
| 166 |
detect_btn = gr.Button("Detect AI Probability")
|