Jesse Karmani commited on
Commit
24fe65c
·
1 Parent(s): b0cf0db

Take an input string in the main translator method

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -68,6 +68,7 @@ def get_dataloader(
68
 
69
 
70
  def main(
 
71
  source_lang: Optional[str],
72
  target_lang: Optional[str],
73
  starting_batch_size: int = 8,
@@ -89,8 +90,10 @@ def main(
89
  trust_remote_code: bool = False,
90
  ):
91
  accelerator = Accelerator()
92
- sentences_path = "sample_text/en.small.txt"
93
- output_path = "sample_text/en2es.translation.m2m100_12B.txt"
 
 
94
 
95
  if force_auto_device_map and starting_batch_size >= 64:
96
  print(
@@ -536,5 +539,5 @@ def main(
536
  # trust_remote_code=args.trust_remote_code,
537
  # )
538
 
539
- demo = gradio.Interface(fn=main, inputs=["textbox", "textbox"], outputs="textbox")
540
  demo.launch(share=True)
 
68
 
69
 
70
  def main(
71
+ input_string: str,
72
  source_lang: Optional[str],
73
  target_lang: Optional[str],
74
  starting_batch_size: int = 8,
 
90
  trust_remote_code: bool = False,
91
  ):
92
  accelerator = Accelerator()
93
+ sentences_path = "input.txt"
94
+ output_path = "output.txt"
95
+ with open(sentences_path, "w", encoding="utf-8") as f:
96
+ f.write(input_string)
97
 
98
  if force_auto_device_map and starting_batch_size >= 64:
99
  print(
 
539
  # trust_remote_code=args.trust_remote_code,
540
  # )
541
 
542
+ demo = gradio.Interface(fn=main, inputs=["textbox", "textbox", "textbox"], outputs="textbox")
543
  demo.launch(share=True)