Qilex commited on
Commit
f609671
β€’
1 Parent(s): c18f72a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
+
4
+ tokenizer = AutoTokenizer.from_pretrained("facebook/bart-base")
5
+ infer = AutoModelForSeq2SeqLM.from_pretrained("Qilex/bart-largeEN-ME")
6
+
7
+ def translate(sentence):
8
+ input_ids = tokenizer(sentence, return_tensors="pt").input_ids
9
+ outputs = infer.generate(input_ids, max_new_tokens = len(sample.split(' '))*10)
10
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
11
+
12
+ title = "English to Middle English Translator"
13
+ description = """
14
+ This translator is trained on about 80,000 English/Middle English paired sentences.
15
+ <br>
16
+ It's still a work in progress.
17
+ """
18
+ article = ''''''
19
+ gr.Interface(
20
+ fn=translate,
21
+ inputs=gr.Textbox(lines=1, placeholder="Enter text to translate."),
22
+ outputs="text",
23
+ title=title,
24
+ description=description,
25
+ article = article,
26
+ ).launch()