Spaces:
Runtime error
Runtime error
File size: 550 Bytes
e85db76 a8092e0 e85db76 a8092e0 e85db76 a8092e0 e85db76 a8092e0 e85db76 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import gradio as gr
import torch
from germantoenglish import Seq2SeqTransformer, translate, greedy_decode
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = model.load_state_dict(torch.load('./transformer_model.pth', map_location=device))
model.eval()
if __name__ == "__main__":
iface = gr.Interface(
fn=translate,
inputs=[
gr.components.Textbox(label="Text")
],
outputs=["text"],
cache_examples=False,
title="GermanToEnglish",
)
iface.launch(share=True)
|