Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
| 3 |
+
|
| 4 |
+
model_name = "flexudy/t5-base-multi-sentence-doctor"
|
| 5 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 6 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
| 7 |
+
|
| 8 |
+
def correct_sentences(text):
|
| 9 |
+
inputs = tokenizer.encode(text, return_tensors="pt", truncation=True)
|
| 10 |
+
outputs = model.generate(inputs, max_length=512)
|
| 11 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 12 |
+
|
| 13 |
+
demo = gr.Interface(fn=correct_sentences, inputs="text", outputs="text", title="Sentence Doctor")
|
| 14 |
+
|
| 15 |
+
demo.launch()
|