zaanind commited on
Commit
7f7a6d9
1 Parent(s): 4c5c04e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -1,6 +1,7 @@
1
- import gradio as gr
2
  from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
3
 
 
4
  model_name = "zaanind/nllb-ensi-v1-tuning"
5
  tokenizer = AutoTokenizer.from_pretrained(model_name)
6
  model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
@@ -15,10 +16,17 @@ def translate(text):
15
  translation = tokenizer.decode(translated_tokens[0], skip_special_tokens=True)
16
  return translation
17
 
18
- iface = gr.Interface(fn=translate,
19
- inputs="text",
20
- outputs="text",
21
- title="EnSi NMT",
22
- description="This is a demo and rest api for ensi nmt by @zaanind."
23
- )
24
- iface.launch()
 
 
 
 
 
 
 
 
1
+ import gradio
2
  from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
3
 
4
+
5
  model_name = "zaanind/nllb-ensi-v1-tuning"
6
  tokenizer = AutoTokenizer.from_pretrained(model_name)
7
  model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
 
16
  translation = tokenizer.decode(translated_tokens[0], skip_special_tokens=True)
17
  return translation
18
 
19
+
20
+ def nmtapifunc(text):
21
+ text = translate(text)
22
+ return text
23
+
24
+ gradio_interface = gradio.Interface(
25
+ fn=nmtapifunc,
26
+ inputs="text",
27
+ outputs="text",
28
+ title="En-Si NMT",
29
+ description="",
30
+ article="© zaanind 2024"
31
+ )
32
+ gradio_interface.launch()