Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,7 +15,7 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
| 15 |
# Humanizer function
|
| 16 |
def humanize_text(ai_text):
|
| 17 |
if not ai_text.strip():
|
| 18 |
-
return "⚠️ Please enter some text."
|
| 19 |
|
| 20 |
# Prompt for rewriting
|
| 21 |
prompt = (
|
|
@@ -34,38 +34,25 @@ def humanize_text(ai_text):
|
|
| 34 |
)
|
| 35 |
humanized = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 36 |
|
| 37 |
-
|
| 38 |
-
feedback_prompt = (
|
| 39 |
-
"Analyze the following text and provide constructive feedback on how it was humanized. "
|
| 40 |
-
"Highlight improvements and remaining issues:\n\n"
|
| 41 |
-
f"Original: {ai_text}\n\n"
|
| 42 |
-
f"Humanized: {humanized}\n\n"
|
| 43 |
-
"Feedback:"
|
| 44 |
-
)
|
| 45 |
-
fb_inputs = tokenizer(feedback_prompt, return_tensors="pt")
|
| 46 |
-
fb_outputs = model.generate(**fb_inputs, max_new_tokens=250, temperature=0.8, top_p=0.9)
|
| 47 |
-
feedback = tokenizer.decode(fb_outputs[0], skip_special_tokens=True)
|
| 48 |
-
|
| 49 |
-
return humanized, feedback
|
| 50 |
|
| 51 |
# Gradio UI
|
| 52 |
with gr.Blocks() as demo:
|
| 53 |
-
gr.Markdown("## ✨ AI Text Humanizer
|
| 54 |
-
gr.Markdown("Paste AI-generated text below, and get a natural, human-like rewrite
|
| 55 |
|
| 56 |
with gr.Row():
|
| 57 |
ai_input = gr.Textbox(label="AI-Generated Text", placeholder="Paste your AI text here...", lines=10)
|
| 58 |
|
| 59 |
with gr.Row():
|
| 60 |
humanized_output = gr.Textbox(label="✅ Humanized Text", lines=10)
|
| 61 |
-
feedback_output = gr.Textbox(label="💡 Feedback", lines=10)
|
| 62 |
|
| 63 |
run_button = gr.Button("🔄 Humanize Now")
|
| 64 |
|
| 65 |
run_button.click(
|
| 66 |
fn=humanize_text,
|
| 67 |
inputs=ai_input,
|
| 68 |
-
outputs=
|
| 69 |
)
|
| 70 |
|
| 71 |
demo.launch()
|
|
|
|
| 15 |
# Humanizer function
|
| 16 |
def humanize_text(ai_text):
|
| 17 |
if not ai_text.strip():
|
| 18 |
+
return "⚠️ Please enter some text."
|
| 19 |
|
| 20 |
# Prompt for rewriting
|
| 21 |
prompt = (
|
|
|
|
| 34 |
)
|
| 35 |
humanized = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 36 |
|
| 37 |
+
return humanized
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
# Gradio UI
|
| 40 |
with gr.Blocks() as demo:
|
| 41 |
+
gr.Markdown("## ✨ AI Text Humanizer")
|
| 42 |
+
gr.Markdown("Paste AI-generated text below, and get a natural, human-like rewrite.")
|
| 43 |
|
| 44 |
with gr.Row():
|
| 45 |
ai_input = gr.Textbox(label="AI-Generated Text", placeholder="Paste your AI text here...", lines=10)
|
| 46 |
|
| 47 |
with gr.Row():
|
| 48 |
humanized_output = gr.Textbox(label="✅ Humanized Text", lines=10)
|
|
|
|
| 49 |
|
| 50 |
run_button = gr.Button("🔄 Humanize Now")
|
| 51 |
|
| 52 |
run_button.click(
|
| 53 |
fn=humanize_text,
|
| 54 |
inputs=ai_input,
|
| 55 |
+
outputs=humanized_output
|
| 56 |
)
|
| 57 |
|
| 58 |
demo.launch()
|