codelx24 commited on
Commit
5cc756c
·
verified ·
1 Parent(s): 4f0feee

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -11
app.py CHANGED
@@ -1,16 +1,28 @@
1
  import gradio as gr
2
- from authormist import Humanizer
3
 
4
- humanizer = Humanizer()
 
 
 
5
 
6
- def humanize(text):
7
- return humanizer.humanize(text)
 
 
 
 
8
 
9
- demo = gr.Interface(
10
- fn=humanize,
11
- inputs="textbox",
12
- outputs="textbox",
13
- title="AuthorMist AI Humanizer"
14
- )
15
 
16
- demo.launch()
 
 
 
 
 
 
 
 
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()