siddhantuniyal commited on
Commit
10bc260
1 Parent(s): 4e66ed1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -1,25 +1,19 @@
1
 
2
- from gramformer import Gramformer
3
- import torch
4
  import gradio as gr
5
 
6
- def set_seed(seed):
7
- torch.manual_seed(seed)
8
- if torch.cuda.is_available():
9
- torch.cuda.manual_seed_all(seed)
10
 
11
- set_seed(1212)
12
-
13
- gf = Gramformer(models = 1, use_gpu=False) # 1=corrector, 2=detector
 
14
 
15
  def correct(text):
16
  sentences = text.split(".")
17
  output = ""
18
  for sentence in sentences:
19
  sentence += "."
20
- correctedSet = gf.correct(sentence , max_candidates=1)
21
- for corrected in correctedSet:
22
- output += corrected
23
  return output
24
 
25
  iface = gr.Interface(
@@ -31,3 +25,6 @@ iface = gr.Interface(
31
 
32
  # Launch the Gradio interface
33
  iface.launch(share=True)
 
 
 
 
1
 
2
+ from transformers import pipeline
 
3
  import gradio as gr
4
 
 
 
 
 
5
 
6
+ corrector = pipeline(
7
+ 'text2text-generation',
8
+ 'pszemraj/flan-t5-large-grammar-synthesis',
9
+ )
10
 
11
  def correct(text):
12
  sentences = text.split(".")
13
  output = ""
14
  for sentence in sentences:
15
  sentence += "."
16
+ output += corrector(sentence)
 
 
17
  return output
18
 
19
  iface = gr.Interface(
 
25
 
26
  # Launch the Gradio interface
27
  iface.launch(share=True)
28
+
29
+
30
+