Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import
|
3 |
import torch
|
4 |
|
5 |
@st.cache_resource
|
6 |
def load_model():
|
7 |
-
tokenizer =
|
8 |
-
model =
|
9 |
return tokenizer, model
|
10 |
|
11 |
def humanize_text(input_text):
|
@@ -14,10 +14,10 @@ def humanize_text(input_text):
|
|
14 |
model = model.to(device)
|
15 |
|
16 |
text = "paraphrase: " + input_text + " </s>"
|
17 |
-
encoding = tokenizer.encode_plus(text,
|
18 |
input_ids, attention_mask = encoding["input_ids"].to(device), encoding["attention_mask"].to(device)
|
19 |
|
20 |
-
|
21 |
input_ids=input_ids,
|
22 |
attention_mask=attention_mask,
|
23 |
max_length=256,
|
@@ -28,14 +28,12 @@ def humanize_text(input_text):
|
|
28 |
num_return_sequences=1
|
29 |
)
|
30 |
|
31 |
-
|
32 |
-
return paraphrased_text
|
33 |
|
34 |
-
# Streamlit
|
35 |
st.set_page_config(page_title="Humanize AI Text", layout="centered")
|
36 |
-
|
37 |
-
st.
|
38 |
-
st.write("Paste your AI-generated text and we'll paraphrase it to make it sound more natural and human-like.")
|
39 |
|
40 |
input_text = st.text_area("Enter AI-Generated Text", height=300)
|
41 |
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
3 |
import torch
|
4 |
|
5 |
@st.cache_resource
|
6 |
def load_model():
|
7 |
+
tokenizer = T5Tokenizer.from_pretrained("Vamsi/T5_Paraphrase_Paws")
|
8 |
+
model = T5ForConditionalGeneration.from_pretrained("Vamsi/T5_Paraphrase_Paws")
|
9 |
return tokenizer, model
|
10 |
|
11 |
def humanize_text(input_text):
|
|
|
14 |
model = model.to(device)
|
15 |
|
16 |
text = "paraphrase: " + input_text + " </s>"
|
17 |
+
encoding = tokenizer.encode_plus(text, padding="max_length", return_tensors="pt", max_length=256, truncation=True)
|
18 |
input_ids, attention_mask = encoding["input_ids"].to(device), encoding["attention_mask"].to(device)
|
19 |
|
20 |
+
output = model.generate(
|
21 |
input_ids=input_ids,
|
22 |
attention_mask=attention_mask,
|
23 |
max_length=256,
|
|
|
28 |
num_return_sequences=1
|
29 |
)
|
30 |
|
31 |
+
return tokenizer.decode(output[0], skip_special_tokens=True)
|
|
|
32 |
|
33 |
+
# Streamlit Interface
|
34 |
st.set_page_config(page_title="Humanize AI Text", layout="centered")
|
35 |
+
st.title("🧠 Humanize AI Text")
|
36 |
+
st.write("Make AI-generated text sound more human to evade detection.")
|
|
|
37 |
|
38 |
input_text = st.text_area("Enter AI-Generated Text", height=300)
|
39 |
|