Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,28 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
|
4 |
-
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
title="AuthorMist AI Humanizer"
|
14 |
-
)
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
|
4 |
+
# Load the AuthorMist model and tokenizer
|
5 |
+
model_name = "authormist/authormist-originality"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
8 |
|
9 |
+
# Function to humanize input text
|
10 |
+
def humanize_text(text):
|
11 |
+
prompt = f"Please paraphrase the following text to make it human-like:\n\n{text}\n\nParaphrased text:"
|
12 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
13 |
+
outputs = model.generate(inputs.input_ids, max_new_tokens=512, temperature=0.7, top_p=0.9)
|
14 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
15 |
|
16 |
+
# Extract only the paraphrased part
|
17 |
+
if "Paraphrased text:" in response:
|
18 |
+
return response.split("Paraphrased text:")[1].strip()
|
19 |
+
return response.strip()
|
|
|
|
|
20 |
|
21 |
+
# Launch Gradio UI
|
22 |
+
gr.Interface(
|
23 |
+
fn=humanize_text,
|
24 |
+
inputs=gr.Textbox(lines=10, placeholder="Paste AI-written text here..."),
|
25 |
+
outputs="text",
|
26 |
+
title="AuthorMist AI Humanizer",
|
27 |
+
description="Turns AI-generated text into human-like writing to reduce detection by tools like GPTZero."
|
28 |
+
).launch()
|