Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,8 +4,8 @@ import torch
|
|
4 |
|
5 |
@st.cache_resource
|
6 |
def load_model():
|
7 |
-
tokenizer = T5Tokenizer.from_pretrained("
|
8 |
-
model = T5ForConditionalGeneration.from_pretrained("
|
9 |
return tokenizer, model
|
10 |
|
11 |
def humanize_text(input_text):
|
@@ -13,24 +13,31 @@ def humanize_text(input_text):
|
|
13 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
14 |
model = model.to(device)
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
output = model.generate(
|
21 |
input_ids=input_ids,
|
22 |
attention_mask=attention_mask,
|
23 |
-
max_length=
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
early_stopping=True,
|
28 |
-
num_return_sequences=1
|
29 |
)
|
30 |
|
31 |
return tokenizer.decode(output[0], skip_special_tokens=True)
|
32 |
|
33 |
-
# Streamlit
|
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.")
|
|
|
4 |
|
5 |
@st.cache_resource
|
6 |
def load_model():
|
7 |
+
tokenizer = T5Tokenizer.from_pretrained("ramsrigouthamg/t5_paraphraser")
|
8 |
+
model = T5ForConditionalGeneration.from_pretrained("ramsrigouthamg/t5_paraphraser")
|
9 |
return tokenizer, model
|
10 |
|
11 |
def humanize_text(input_text):
|
|
|
13 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
14 |
model = model.to(device)
|
15 |
|
16 |
+
prompt = f"paraphrase this text to make it sound more human and natural: {input_text} </s>"
|
17 |
+
|
18 |
+
encoding = tokenizer.encode_plus(
|
19 |
+
prompt,
|
20 |
+
padding="max_length",
|
21 |
+
return_tensors="pt",
|
22 |
+
max_length=512,
|
23 |
+
truncation=True
|
24 |
+
)
|
25 |
+
|
26 |
+
input_ids = encoding["input_ids"].to(device)
|
27 |
+
attention_mask = encoding["attention_mask"].to(device)
|
28 |
|
29 |
output = model.generate(
|
30 |
input_ids=input_ids,
|
31 |
attention_mask=attention_mask,
|
32 |
+
max_length=512,
|
33 |
+
num_beams=5,
|
34 |
+
no_repeat_ngram_size=3,
|
35 |
+
early_stopping=True
|
|
|
|
|
36 |
)
|
37 |
|
38 |
return tokenizer.decode(output[0], skip_special_tokens=True)
|
39 |
|
40 |
+
# Streamlit UI
|
41 |
st.set_page_config(page_title="Humanize AI Text", layout="centered")
|
42 |
st.title("🧠 Humanize AI Text")
|
43 |
st.write("Make AI-generated text sound more human to evade detection.")
|