leslyarun's picture
Update app.py
cf1f5b8
raw
history blame
766 Bytes
import gradio as gr
from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForSeq2SeqLM
from optimum.pipelines import pipeline
def check_grammar(sentence):
tokenizer = AutoTokenizer.from_pretrained("leslyarun/grammatical-error-correction-quantized")
model = ORTModelForSeq2SeqLM.from_pretrained("leslyarun/grammatical-error-correction-quantized")
text2text_generator = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
output = text2text_generator("grammar: " + sentence)
return output
demo = gr.Interface(check_grammar, inputs=['text'],
outputs="text",
title = "English Grammar Corrector")
if __name__ == "__main__":
demo.launch(debug=True)