Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,5 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
import torch
|
| 4 |
-
|
| 5 |
-
# Load T5 model
|
| 6 |
-
model_name = "t5-base"
|
| 7 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 8 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
| 9 |
|
|
@@ -11,14 +7,7 @@ def humanize_text(text, tone):
|
|
| 11 |
if not text.strip():
|
| 12 |
return "⚠️ Please enter text.", "❌ Empty input"
|
| 13 |
|
| 14 |
-
|
| 15 |
-
prefix = {
|
| 16 |
-
"Academic": "paraphrase this sentence into a refined academic style:",
|
| 17 |
-
"Professional": "rephrase this text in a formal and professional tone:",
|
| 18 |
-
"Conversational": "rewrite this text in a natural conversational style:"
|
| 19 |
-
}[tone]
|
| 20 |
-
|
| 21 |
-
prompt = f"{prefix} {text}"
|
| 22 |
|
| 23 |
try:
|
| 24 |
inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=512)
|
|
@@ -34,22 +23,4 @@ def humanize_text(text, tone):
|
|
| 34 |
except Exception as e:
|
| 35 |
return f"⚠️ Error: {str(e)}", "❌ Model error"
|
| 36 |
|
| 37 |
-
# Build interface
|
| 38 |
-
iface = gr.Interface(
|
| 39 |
-
fn=humanize_text,
|
| 40 |
-
inputs=[
|
| 41 |
-
gr.Textbox(lines=8, label="✍️ Enter your text"),
|
| 42 |
-
gr.Radio(["Academic", "Professional", "Conversational"], label="Tone", value="Academic")
|
| 43 |
-
],
|
| 44 |
-
outputs=[
|
| 45 |
-
gr.Textbox(lines=10, label="🧠 Refined Academic Rewrite"),
|
| 46 |
-
gr.Textbox(label="System Status")
|
| 47 |
-
],
|
| 48 |
-
title="🕌 Zawiyah AI Collective – Attention-Based Humanizer AI",
|
| 49 |
-
description="Transforms ordinary text into refined, academic, or professional language using a T5 transformer model."
|
| 50 |
-
)
|
| 51 |
-
|
| 52 |
-
if __name__ == "__main__":
|
| 53 |
-
iface.launch()
|
| 54 |
-
|
| 55 |
|
|
|
|
| 1 |
+
# Load better paraphraser model
|
| 2 |
+
model_name = "Vamsi/T5_Paraphrase_Paws"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 4 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
| 5 |
|
|
|
|
| 7 |
if not text.strip():
|
| 8 |
return "⚠️ Please enter text.", "❌ Empty input"
|
| 9 |
|
| 10 |
+
prompt = f"paraphrase: {text} </s>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
try:
|
| 13 |
inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=512)
|
|
|
|
| 23 |
except Exception as e:
|
| 24 |
return f"⚠️ Error: {str(e)}", "❌ Model error"
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|