File size: 1,690 Bytes
d51ac59
 
 
650b2b1
d51ac59
a232bc9
650b2b1
d51ac59
 
 
a232bc9
650b2b1
79a5bb7
a232bc9
 
 
 
 
 
 
 
 
650b2b1
 
 
a232bc9
 
 
650b2b1
 
a232bc9
7f9f75d
a232bc9
06d8742
a232bc9
06d8742
a232bc9
384af3a
650b2b1
e1cfd8c
a232bc9
 
 
 
 
 
650b2b1
e1cfd8c
384af3a
e1cfd8c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

# Model name (your fine-tuned model)
MODEL_NAME = "Sazid2/assamese-english-translator"

# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME)

def translate(text):
    """Translate Assamese → English"""
    if not text.strip():
        return "⚠️ Please enter Assamese text."
    
    inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
    outputs = model.generate(**inputs, max_length=128)
    translated = tokenizer.decode(outputs[0], skip_special_tokens=True)
    return translated

title = "🌐 Assamese → English Translator"
description = """
### 🧠 Fine-tuned Neural Machine Translation  
This model translates **Assamese sentences to English** using a custom **Assamese-English parallel corpus (~20k sentences)**.  
It is built on top of the `Helsinki-NLP/opus-mt-mul-en` architecture.

- 🔤 **Source language:** Assamese  
- 🌍 **Target language:** English  
- 🧩 **BLEU Score:** 38.02  
- 🧠 **Framework:** Hugging Face Transformers  
"""

examples = [
    ["মই কামলৈ গৈ আছো।"],
    ["তুমি ক'ত আছা?"],
    ["তেও অত্যন্ত ধুনীয়া।"]
]

# Create Gradio interface
demo = gr.Interface(
    fn=translate,
    inputs=gr.Textbox(label="Enter Assamese text"),
    outputs=gr.Textbox(label="English Translation"),
    title=title,
    description=description,
    examples=examples,
    article="---\n**Fine-tuned by:** Abu Sazid Ahmed 🧑‍💻",
)

if __name__ == "__main__":
    demo.launch()