TwentyNine commited on
Commit
f7c5310
·
verified ·
1 Parent(s): 59c9f9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -1,3 +1,20 @@
1
- import gradio as gr
 
2
 
3
- gr.load("models/TwentyNine/byt5-ain-kana-latin-converter-v1").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr, transformers
2
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
 
4
+ tokenizer = AutoTokenizer.from_pretrained("TwentyNine/byt5-ain-kana-latin-converter-v1")
5
+ model = AutoModelForSeq2SeqLM.from_pretrained("TwentyNine/byt5-ain-kana-latin-converter-v1")
6
+
7
+ def transcribe(input_str):
8
+ input_enc = tokenizer.encode(input_str, return_tensors='pt')
9
+ output_enc = model.generate(input_ids, max_length=256)
10
+ return tokenizer.decode(output_enc[0], skip_special_tokens=True
11
+
12
+ gradio_app = gr.Interface(
13
+ transcribe,
14
+ inputs=gr.Textbox(label='Input (kana)', value='', placeholder='', info='Ainu text written in Japanese katakana (input).', interactive=True, autofocus=True)
15
+ outputs=gr.Textbox(label='Output (alphabet)', info='Ainu text written in the Latin alphabet (output).')
16
+ title="BYT5 Ainu Kana-Latin Converter (V1)",
17
+ )
18
+
19
+ if __name__ == "__main__":
20
+ gradio_app.launch()