Spaces:
Runtime error
Runtime error
from gramformer import Gramformer | |
import torch | |
import gradio as gr | |
def set_seed(seed): | |
torch.manual_seed(seed) | |
if torch.cuda.is_available(): | |
torch.cuda.manual_seed_all(seed) | |
set_seed(1212) | |
gf = Gramformer(models = 1, use_gpu=False) # 1=corrector, 2=detector | |
def correct(text): | |
sentences = text.split(".") | |
output = "" | |
for sentence in sentences: | |
sentence += "." | |
correctedSet = gf.correct(sentence , max_candidates=1) | |
for corrected in correctedSet: | |
output += corrected | |
print(corrected) | |
return output | |
iface = gr.Interface( | |
fn= correct, | |
inputs= "text", | |
outputs= "text", | |
title="Aeravat Grammar Correction", | |
) | |
# Launch the Gradio interface | |
iface.launch(share=True) | |