mutij8 commited on
Commit
e13e03e
·
verified ·
1 Parent(s): 06d26dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -15,7 +15,7 @@ def load_model_once():
15
  if model is not None:
16
  return tokenizer, model
17
 
18
- print("⏳ ZeroGPU allocated! Loading model into VRAM...")
19
  tokenizer = AutoTokenizer.from_pretrained(adapter_model_id)
20
 
21
  base_model = AutoModelForCausalLM.from_pretrained(
@@ -27,7 +27,7 @@ def load_model_once():
27
  print("✅ Model loaded successfully on GPU!")
28
  return tokenizer, model
29
 
30
- @spaces.GPU
31
  def humanize_and_correct(paragraph):
32
  paragraph = paragraph.strip()
33
  if not paragraph:
@@ -36,13 +36,13 @@ def humanize_and_correct(paragraph):
36
  tok, mod = load_model_once()
37
  word_count = len(paragraph.split())
38
 
39
- dual_instruction = f'''You are an expert academic editor and researcher. Your task is to simultaneously fix all grammatical errors, spelling mistakes, and awkward phrasing while humanizing the text.
40
  - Tone: Write with natural human imperfection, varied sentence lengths, and stylistic asymmetry.
41
  - Rule 1: Output MUST be between {int(word_count*0.85)} and {int(word_count*1.15)} words.
42
  - Rule 2: Fix any grammar, punctuation, tense inconsistencies, or syntax errors present in the input text.
43
  - Rule 3: Force clause inversion and structural variety to eliminate AI detection signatures and ensure low plagiarism.
44
  - Rule 4: Keep all inline citations (e.g. [1] or (Smith, 2023)) 100% intact and correctly placed.
45
- - Rule 5: Output ONLY the fully corrected and humanized text.'''
46
 
47
  messages = [
48
  {"role": "system", "content": dual_instruction},
@@ -67,9 +67,9 @@ def humanize_and_correct(paragraph):
67
 
68
  interface = gr.Interface(
69
  fn=humanize_and_correct,
70
- inputs=gr.Textbox(lines=10, placeholder="Enter text with grammar errors or AI style here..."),
71
- outputs=gr.Textbox(lines=10, label="Grammar-Corrected & Humanized Output"),
72
- title="Dual-Action Academic Humanizer & Grammar Corrector",
73
  description="Simultaneously fixes grammatical errors and transforms AI or flawed text into Turnitin-verified human prose."
74
  )
75
 
 
15
  if model is not None:
16
  return tokenizer, model
17
 
18
+ print("⏳ ZeroGPU allocated! Loading base model and fine-tuned adapter...")
19
  tokenizer = AutoTokenizer.from_pretrained(adapter_model_id)
20
 
21
  base_model = AutoModelForCausalLM.from_pretrained(
 
27
  print("✅ Model loaded successfully on GPU!")
28
  return tokenizer, model
29
 
30
+ @spaces.GPU(duration=120)
31
  def humanize_and_correct(paragraph):
32
  paragraph = paragraph.strip()
33
  if not paragraph:
 
36
  tok, mod = load_model_once()
37
  word_count = len(paragraph.split())
38
 
39
+ dual_instruction = f"""You are an expert academic editor and researcher. Your task is to simultaneously fix all grammatical errors, spelling mistakes, and awkward phrasing while humanizing the text.
40
  - Tone: Write with natural human imperfection, varied sentence lengths, and stylistic asymmetry.
41
  - Rule 1: Output MUST be between {int(word_count*0.85)} and {int(word_count*1.15)} words.
42
  - Rule 2: Fix any grammar, punctuation, tense inconsistencies, or syntax errors present in the input text.
43
  - Rule 3: Force clause inversion and structural variety to eliminate AI detection signatures and ensure low plagiarism.
44
  - Rule 4: Keep all inline citations (e.g. [1] or (Smith, 2023)) 100% intact and correctly placed.
45
+ - Rule 5: Output ONLY the fully corrected and humanized text."""
46
 
47
  messages = [
48
  {"role": "system", "content": dual_instruction},
 
67
 
68
  interface = gr.Interface(
69
  fn=humanize_and_correct,
70
+ inputs=gr.Textbox(lines=8, placeholder="Paste your text with grammar errors or AI style here..."),
71
+ outputs=gr.Textbox(lines=8, label="Grammar-Corrected & Humanized Output"),
72
+ title="Turnitin-Calibrated Dual-Action Academic Humanizer",
73
  description="Simultaneously fixes grammatical errors and transforms AI or flawed text into Turnitin-verified human prose."
74
  )
75