Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- .gitignore +1 -0
- app.py +39 -0
- requirements.txt +8 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
__pycache__/
|
app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import spacy
|
| 4 |
+
import language_tool_python
|
| 5 |
+
from transformers import pipeline
|
| 6 |
+
|
| 7 |
+
# --- load lightweight models once ---
|
| 8 |
+
nlp = spacy.load("en_core_web_sm")
|
| 9 |
+
tool = language_tool_python.LanguageTool('en-US')
|
| 10 |
+
para = pipeline("text2text-generation", model="Vamsi/T5_Paraphrase_Paws")
|
| 11 |
+
|
| 12 |
+
def humanize(text, tone, strength, freeze):
|
| 13 |
+
# detect entities to lock
|
| 14 |
+
locked = [(ent.text, ent.label_) for ent in nlp(text).ents] if freeze else []
|
| 15 |
+
# paraphrase
|
| 16 |
+
paraphrased = para(text, max_length=512, do_sample=True, temperature=0.7 * strength / 10)[0]['generated_text']
|
| 17 |
+
# grammar fix
|
| 18 |
+
paraphrased = tool.correct(paraphrased)
|
| 19 |
+
# restore locked entities
|
| 20 |
+
for ent, label in locked:
|
| 21 |
+
paraphrased = re.sub(re.escape(ent), ent, paraphrased, flags=re.IGNORECASE)
|
| 22 |
+
return paraphrased
|
| 23 |
+
|
| 24 |
+
# --- Gradio interface ---
|
| 25 |
+
import re
|
| 26 |
+
iface = gr.Interface(
|
| 27 |
+
fn=humanize,
|
| 28 |
+
inputs=[
|
| 29 |
+
gr.Textbox(label="Paste or type your text here", lines=10, placeholder="Type or paste your AI text…"),
|
| 30 |
+
gr.Dropdown(["Casual", "Academic", "Marketing", "Legal", "Creative"], value="Casual", label="Tone"),
|
| 31 |
+
gr.Slider(1, 10, value=5, label="Humanize Strength (1 = subtle, 10 = aggressive)"),
|
| 32 |
+
gr.Checkbox(label="Lock facts / dates / names")
|
| 33 |
+
],
|
| 34 |
+
outputs=gr.Textbox(label="Humanized text", lines=10),
|
| 35 |
+
title="AI Humanizer – 100 % Free & Unlimited",
|
| 36 |
+
description="Zero sign-up, zero cost. Paste, choose options, click “Submit”."
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==4.8
|
| 2 |
+
spacy==3.7.2
|
| 3 |
+
language-tool-python
|
| 4 |
+
transformers
|
| 5 |
+
torch
|
| 6 |
+
sentencepiece
|
| 7 |
+
nltk
|
| 8 |
+
re
|