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

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -38
app.py CHANGED
@@ -1,46 +1,16 @@
1
  import gradio as gr
2
- from transformers import AutoModelForCausalLM, AutoTokenizer
3
 
4
- # Load model & tokenizer
5
- model_name = "authormist/authormist-originality"
6
- tokenizer = AutoTokenizer.from_pretrained(model_name)
7
- model = AutoModelForCausalLM.from_pretrained(model_name)
8
 
9
- def humanize_text(sop_text):
10
- # 1. Split into paragraphs (double-newline separated)
11
- paras = [p.strip() for p in sop_text.split("\n\n") if p.strip()]
12
- humanized = []
13
-
14
- for p in paras:
15
- # 2. Strong, guiding prompt
16
- prompt = (
17
- "You are a senior design student helping me rewrite my Statement of Purpose paragraph. "
18
- "Make it sound genuine, personal, and conversational—avoid anything too polished or robotic:\n\n"
19
- f"{p}\n\nHumanized:"
20
- )
21
- inputs = tokenizer(prompt, return_tensors="pt")
22
- outputs = model.generate(
23
- inputs.input_ids,
24
- max_new_tokens=256,
25
- temperature=0.85,
26
- top_p=0.96,
27
- do_sample=True
28
- )
29
- text = tokenizer.decode(outputs[0], skip_special_tokens=True)
30
- # 3. Strip off the prompt header and cleanup
31
- text = text.replace("Humanized:", "").strip()
32
- humanized.append(text)
33
-
34
- # 4. Re-join paragraphs with blank lines
35
- return "\n\n".join(humanized)
36
 
37
  demo = gr.Interface(
38
- fn=humanize_text,
39
- inputs=gr.Textbox(lines=20, placeholder="Paste your full SOP here…"),
40
  outputs="textbox",
41
- title="AuthorMist SOP Humanizer",
42
- description="Rewrite your entire SOP paragraph-by-paragraph into a natural, undetectable tone."
43
  )
44
 
45
- if __name__ == "__main__":
46
- demo.launch()
 
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()