Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,22 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
|
4 |
-
from
|
5 |
|
6 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
7 |
model = model.load_state_dict(torch.load('./transformer_model.pth', map_location=device))
|
8 |
model.eval()
|
9 |
|
10 |
if __name__ == "__main__":
|
11 |
-
# Create the Gradio interface
|
12 |
iface = gr.Interface(
|
13 |
-
fn=translate,
|
14 |
inputs=[
|
15 |
-
gr.
|
16 |
|
17 |
],
|
18 |
-
outputs=["text"],
|
19 |
-
cache_examples=False,
|
20 |
-
title="
|
21 |
)
|
22 |
|
23 |
-
# Launch the interface
|
24 |
iface.launch(share=True)
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
|
4 |
+
from germantoenglish import Seq2SeqTransformer, translate, greedy_decode
|
5 |
|
6 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
7 |
model = model.load_state_dict(torch.load('./transformer_model.pth', map_location=device))
|
8 |
model.eval()
|
9 |
|
10 |
if __name__ == "__main__":
|
|
|
11 |
iface = gr.Interface(
|
12 |
+
fn=translate,
|
13 |
inputs=[
|
14 |
+
gr.components.Textbox(label="Text")
|
15 |
|
16 |
],
|
17 |
+
outputs=["text"],
|
18 |
+
cache_examples=False,
|
19 |
+
title="GermanToEnglish",
|
20 |
)
|
21 |
|
|
|
22 |
iface.launch(share=True)
|