siddhantuniyal commited on
Commit
2d23730
·
verified ·
1 Parent(s): 67ddc4b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -1
app.py CHANGED
@@ -1,3 +1,34 @@
 
 
 
1
  import gradio as gr
2
 
3
- gr.load("models/Unbabel/gec-t5_small").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ print(corrected)
24
+ return output
25
+
26
+ iface = gr.Interface(
27
+ fn= correct,
28
+ inputs= "text",
29
+ outputs= "text",
30
+ title="Aeravat Grammar Correction",
31
+ )
32
+
33
+ # Launch the Gradio interface
34
+ iface.launch(share=True)