dalat5 / app.py
crossroderick's picture
Gradio remake
02b7cd5
raw
history blame
2.72 kB
import gradio as gr
from transformers import pipeline
# Load model once
model = pipeline("text2text-generation", model = "crossroderick/dalat5")
def transliterate(text: str) -> str:
"""
Prediction function.
"""
if text.strip() == "":
return "Енгізуді күтуде... жоғарыдағы кириллицаның көмегімен қазақ тілінде сөйлем теріңіз / Awaiting input... type a sentence in Kazakh using Cyrillic script above."
input_text = f"Cyrillic2Latin: {text.strip()}"
output = model(input_text, max_length = 128)[0]["generated_text"]
return output.strip()
# App description (Markdown style)
description = """
# 🇰🇿 DalaT5
Қазақша кириллица → латын графикасының генераторы / Kazakh Cyrillic → Latin Script Generator
---
**[EN]**
DalaT5 is a T5-based model trained to convert natural Kazakh written in **Cyrillic** into fluent **Latin script**, based on the official 2021 alphabet reform of Kazakhstan.
This model is offered as a cultural gesture of respect and curiosity. It accepts modern Kazakh as people write it today - and answers in the language of its future.
**[KZ]**
DalaT5 - **кириллицада** жазылған табиғи қазақ тілін еркін **латын графикасына** ауыстыру үшін дайындалған T5 негізіндегі модель, Қазақстанның 2021 жылғы ресми әліпби реформасына негізделген.
Бұл модель құрмет пен қызығушылықтың мәдени қимылы ретінде ұсынылады. Ол қазіргі қазақ тілін бүгінгі адамдар қалай жазады, солай қабылдайды - және оның болашағының тілінде жауап береді.
🧠 [Model link](https://huggingface.co/crossroderick/dalat5)
🔤 [Kazakhstan 2021 alphabet reform](https://astanatimes.com/2021/02/kazakhstan-presents-new-latin-alphabet-plans-gradual-transition-through-2031/)
"""
# Interface
demo = gr.Interface(
fn = transliterate,
inputs = gr.Textbox(
label = "Қазақ тілінде теріңіз (кириллица) / Type in Kazakh (Cyrillic script)",
placeholder = "Мен қазақ тілінде сөйлеймін.",
lines = 6
),
outputs = gr.Textbox(
label = "Латын графикасының шығуы / Latin script output"
),
title = "🇰🇿 DalaT5 - Kazakh Script Transformer",
description = description,
theme = "default",
allow_flagging = "never"
)
demo.launch()