Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +21 -0
- requirements.txt +4 -0
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
def correct_grammar(sentence):
|
| 5 |
+
model_name = "AventIQ-AI/t5-grammar-correction"
|
| 6 |
+
generator = pipeline("text2text-generation", model=model_name)
|
| 7 |
+
|
| 8 |
+
result = generator(sentence, max_length=256)[0]['generated_text']
|
| 9 |
+
|
| 10 |
+
return result
|
| 11 |
+
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=correct_grammar,
|
| 14 |
+
inputs=gr.Textbox(label="Input Sentence"),
|
| 15 |
+
outputs=gr.Textbox(label="Corrected Sentence"),
|
| 16 |
+
title="T5 Grammar Correction",
|
| 17 |
+
description="Enter a sentence with grammar mistakes, and the model will correct it."
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
if __name__ == "__main__":
|
| 21 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch
|
| 2 |
+
transformers
|
| 3 |
+
gradio
|
| 4 |
+
sentencepiece
|