bobrooos commited on
Commit
ed1493e
1 Parent(s): 179c8fb

stupid reverse reverse stuff for sanity checking

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -14,6 +14,8 @@ model_name.choices = ["English to Hebrew", "Hebrew to English"]
14
  # An output text box displaying the translated text and reverse translated text
15
  translation = gr.outputs.Textbox(label="Translation")
16
  reverse_translation = gr.outputs.Textbox(label="Reverse Translation")
 
 
17
 
18
  # A function for translating text
19
  def translate(model_name, text):
@@ -57,9 +59,20 @@ def translate(model_name, text):
57
  reverse_outputs = reverse_model.generate(reverse_input_ids)
58
  reverse_translation = reverse_tokenizer.decode(reverse_outputs[0], skip_special_tokens=True)
59
 
60
- return forward_translation, reverse_translation
 
 
 
61
 
62
- iface = gr.Interface(fn=translate, inputs=[model_name, "text"], outputs=[translation, reverse_translation])
 
 
 
 
 
 
 
 
63
 
64
  # Launch the interface
65
  iface.launch(share=False)
 
14
  # An output text box displaying the translated text and reverse translated text
15
  translation = gr.outputs.Textbox(label="Translation")
16
  reverse_translation = gr.outputs.Textbox(label="Reverse Translation")
17
+ reverse_reverse_translation = gr.outputs.Textbox(label="Reverse Reverse Translation")
18
+ reverse_reverse_reverse_translation = gr.outputs.Textbox(label="Reverse Reverse Reverse Translation")
19
 
20
  # A function for translating text
21
  def translate(model_name, text):
 
59
  reverse_outputs = reverse_model.generate(reverse_input_ids)
60
  reverse_translation = reverse_tokenizer.decode(reverse_outputs[0], skip_special_tokens=True)
61
 
62
+ # Reverse Reverse translation
63
+ reverse_reverse_input_ids = forward_tokenizer.encode(reverse_translation, return_tensors="pt")
64
+ reverse_reverse_outputs = forward_model.generate(reverse_reverse_input_ids)
65
+ reverse_reverse_translation = forward_tokenizer.decode(reverse_reverse_outputs[0], skip_special_tokens=True)
66
 
67
+ # Reverse Reverse Reverse translation
68
+ reverse_reverse_reverse_input_ids = reverse_tokenizer.encode(reverse_reverse_translation, return_tensors="pt")
69
+ reverse_reverse_reverse_outputs = reverse_model.generate(reverse_reverse_reverse_input_ids)
70
+ reverse_reverse_reverse_translation = reverse_tokenizer.decode(reverse_reverse_reverse_outputs[0], skip_special_tokens=True)
71
+
72
+ # Return the translation
73
+ return forward_translation, reverse_translation, reverse_reverse_translation, reverse_reverse_reverse_translation
74
+
75
+ iface = gr.Interface(fn=translate, inputs=[model_name, "text"], outputs=[translation, reverse_translation, reverse_reverse_translation, reverse_reverse_reverse_translation])
76
 
77
  # Launch the interface
78
  iface.launch(share=False)