Spaces:
Runtime error
Runtime error
File size: 839 Bytes
0e5925a |
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 |
import gradio as gr
from fairseq.models.transformer import TransformerModel
ko2en = TransformerModel.from_pretrained(
'model_artifact',
checkpoint_file='checkpoint_best.pt',
data_name_or_path='model_artifact',
bpe='sentencepiece',
sentencepiece_model='model_artifact/subword_tokenizer_ko.model',
source_lang='ko', target_lang='en'
)
def translate(input):
return ko2en.translate(input)
callback = gr.CSVLogger()
with gr.Blocks() as demo:
gr.Label('웹툰 번역기')
input = gr.Textbox(label="Input")
output = gr.Textbox(label="Output")
input.submit(fn=translate, inputs=input, outputs=output)
btn = gr.Button('오류보고')
callback.setup([input, output], 'flagged')
btn.click(lambda *args: callback.flag(args), [input, output], None, preprocess=False)
demo.launch() |