import streamlit as st text = st.text_area('You is here') ### Run Model from transformers import T5ForConditionalGeneration, T5Tokenizer, AutoTokenizer, AutoModelForSeq2SeqLM import torch torch_device = 'cuda' if torch.cuda.is_available() else 'cpu' tokenizer = AutoTokenizer.from_pretrained('deep-learning-analytics/GrammarCorrector') model = AutoModelForSeq2SeqLM.from_pretrained('deep-learning-analytics/GrammarCorrector').to(torch_device) def correct_grammar(input_text,num_return_sequences=1): batch = tokenizer([input_text],truncation=True,padding='max_length',max_length=64, return_tensors="pt").to(torch_device) translated = model.generate(**batch,max_length=64,num_beams=2, num_return_sequences=num_return_sequences, temperature=1.5) tgt_text = tokenizer.batch_decode(translated, skip_special_tokens=True) return tgt_text if text: result = correct_grammar(text) st.json(result)