Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ from peft import PeftModel
|
|
| 8 |
# tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)
|
| 9 |
# model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
|
| 10 |
|
| 11 |
-
model_path = "Sabbir772/
|
| 12 |
tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)
|
| 13 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
|
| 14 |
model.eval()
|
|
@@ -19,8 +19,8 @@ model.to(device)
|
|
| 19 |
def translate(text, source_lang):
|
| 20 |
if source_lang == "Bangla":
|
| 21 |
prefix = "<BN>"
|
| 22 |
-
elif source_lang == "
|
| 23 |
-
prefix = "<
|
| 24 |
else:
|
| 25 |
return "Invalid language selected."
|
| 26 |
|
|
@@ -37,17 +37,17 @@ def translate(text, source_lang):
|
|
| 37 |
)
|
| 38 |
|
| 39 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 40 |
-
|
| 41 |
# Gradio interface
|
| 42 |
iface = gr.Interface(
|
| 43 |
fn=translate,
|
| 44 |
inputs=[
|
| 45 |
gr.Textbox(label="Input Text"),
|
| 46 |
-
gr.Radio(["Bangla", "
|
| 47 |
],
|
| 48 |
outputs=gr.Textbox(label="Translated Text"),
|
| 49 |
-
title="Bangla ↔
|
| 50 |
-
description="Translate between Bangla and
|
| 51 |
)
|
| 52 |
|
| 53 |
iface.launch()
|
|
|
|
| 8 |
# tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)
|
| 9 |
# model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
|
| 10 |
|
| 11 |
+
model_path = "Sabbir772/banglat5-finetuned-bn-Ch"
|
| 12 |
tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)
|
| 13 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
|
| 14 |
model.eval()
|
|
|
|
| 19 |
def translate(text, source_lang):
|
| 20 |
if source_lang == "Bangla":
|
| 21 |
prefix = "<BN>"
|
| 22 |
+
elif source_lang == "Chatgaiya":
|
| 23 |
+
prefix = "<CH>"
|
| 24 |
else:
|
| 25 |
return "Invalid language selected."
|
| 26 |
|
|
|
|
| 37 |
)
|
| 38 |
|
| 39 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 40 |
+
|
| 41 |
# Gradio interface
|
| 42 |
iface = gr.Interface(
|
| 43 |
fn=translate,
|
| 44 |
inputs=[
|
| 45 |
gr.Textbox(label="Input Text"),
|
| 46 |
+
gr.Radio(["Bangla", "Chatgaiya"], label="Source Language")
|
| 47 |
],
|
| 48 |
outputs=gr.Textbox(label="Translated Text"),
|
| 49 |
+
title="Bangla ↔ Chatgaiya Dialect Translator (Fine-tuned T5)",
|
| 50 |
+
description="Translate between Bangla and Chatgaiya using a LoRA-finetuned model."
|
| 51 |
)
|
| 52 |
|
| 53 |
iface.launch()
|