bazil3814 commited on
Commit
44193e6
·
verified ·
1 Parent(s): ab16801

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -1,11 +1,11 @@
1
  import streamlit as st
2
- from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
  import torch
4
 
5
  @st.cache_resource
6
  def load_model():
7
- tokenizer = AutoTokenizer.from_pretrained("ramsrigouthamg/t5_paraphraser")
8
- model = AutoModelForSeq2SeqLM.from_pretrained("ramsrigouthamg/t5_paraphraser")
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, max_length=256, padding='max_length', return_tensors="pt", truncation=True)
18
  input_ids, attention_mask = encoding["input_ids"].to(device), encoding["attention_mask"].to(device)
19
 
20
- outputs = model.generate(
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
- paraphrased_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
32
- return paraphrased_text
33
 
34
- # Streamlit UI
35
  st.set_page_config(page_title="Humanize AI Text", layout="centered")
36
-
37
- st.title("🧠 Humanize AI Text to Evade Detection")
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