Spaces:
Sleeping
Sleeping
Zaheer786124
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
+
|
4 |
+
# Load the Hugging Face model
|
5 |
+
@st.cache_resource
|
6 |
+
def load_model():
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained("t5-small") # Change model if needed
|
8 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("t5-small")
|
9 |
+
return tokenizer, model
|
10 |
+
|
11 |
+
tokenizer, model = load_model()
|
12 |
+
|
13 |
+
# App UI
|
14 |
+
st.title("Paraphrasing Tool - AI to Human")
|
15 |
+
st.write("Paste your AI-generated text below to humanize it:")
|
16 |
+
|
17 |
+
input_text = st.text_area("Enter text here:")
|
18 |
+
if st.button("Paraphrase"):
|
19 |
+
if input_text.strip():
|
20 |
+
with st.spinner("Paraphrasing..."):
|
21 |
+
inputs = tokenizer.encode("paraphrase: " + input_text, return_tensors="pt", max_length=512, truncation=True)
|
22 |
+
outputs = model.generate(inputs, max_length=512, num_beams=4, early_stopping=True)
|
23 |
+
paraphrased_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
24 |
+
st.success("Here is the paraphrased text:")
|
25 |
+
st.write(paraphrased_text)
|
26 |
+
else:
|
27 |
+
st.error("Please enter some text to paraphrase.")
|