asd
Browse files
app.py
CHANGED
@@ -208,9 +208,9 @@ classifier_tokenizer = AutoTokenizer.from_pretrained(classifier_model_name)
|
|
208 |
classifier_model = AutoModelForSequenceClassification.from_pretrained(classifier_model_name).to(device)
|
209 |
|
210 |
# Initialize grammar correction model and tokenizer
|
211 |
-
grammar_model_name = "
|
212 |
-
grammar_tokenizer = AutoTokenizer.from_pretrained(grammar_model_name
|
213 |
-
grammar_model = T5ForConditionalGeneration.from_pretrained(grammar_model_name
|
214 |
|
215 |
# Initialize sentence splitter
|
216 |
splitter = SentenceSplitter(language='en')
|
@@ -229,6 +229,7 @@ def correct_grammar(text):
|
|
229 |
inputs = grammar_tokenizer(f'Fix grammatical errors in this sentence: {text}', return_tensors="pt").input_ids.to(device)
|
230 |
outputs = grammar_model.generate(inputs, max_length=256)
|
231 |
corrected_text = grammar_tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
|
232 |
return corrected_text
|
233 |
|
234 |
@spaces.GPU
|
|
|
208 |
classifier_model = AutoModelForSequenceClassification.from_pretrained(classifier_model_name).to(device)
|
209 |
|
210 |
# Initialize grammar correction model and tokenizer
|
211 |
+
grammar_model_name = "grammarly/coedit-large"
|
212 |
+
grammar_tokenizer = AutoTokenizer.from_pretrained(grammar_model_name)
|
213 |
+
grammar_model = T5ForConditionalGeneration.from_pretrained(grammar_model_name).to(device)
|
214 |
|
215 |
# Initialize sentence splitter
|
216 |
splitter = SentenceSplitter(language='en')
|
|
|
229 |
inputs = grammar_tokenizer(f'Fix grammatical errors in this sentence: {text}', return_tensors="pt").input_ids.to(device)
|
230 |
outputs = grammar_model.generate(inputs, max_length=256)
|
231 |
corrected_text = grammar_tokenizer.decode(outputs[0], skip_special_tokens=True)
|
232 |
+
print(corrected_text)
|
233 |
return corrected_text
|
234 |
|
235 |
@spaces.GPU
|