Spaces:
Sleeping
Sleeping
Update models new
Browse files
app.py
CHANGED
|
@@ -1,14 +1,10 @@
|
|
| 1 |
-
# app.py for Gradio
|
| 2 |
import gradio as gr
|
| 3 |
-
from transformers import
|
| 4 |
|
| 5 |
-
|
| 6 |
-
model = AutoModelForSeq2SeqLM.from_pretrained("bmd1905/vietnamese-correction-v2")
|
| 7 |
|
| 8 |
def add_diacritics(text):
|
| 9 |
-
|
| 10 |
-
outputs = model.generate(**inputs, max_new_tokens=256)
|
| 11 |
-
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 12 |
|
| 13 |
-
demo = gr.Interface(fn=add_diacritics, inputs="text", outputs="text", title="Vietnamese Diacritics
|
| 14 |
demo.launch()
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
corrector = pipeline("text2text-generation", model="bmd1905/vietnamese-correction")
|
|
|
|
| 5 |
|
| 6 |
def add_diacritics(text):
|
| 7 |
+
return corrector(text, max_length=128)[0]["generated_text"]
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
demo = gr.Interface(fn=add_diacritics, inputs="text", outputs="text", title="Vietnamese Diacritics Corrector")
|
| 10 |
demo.launch()
|