TiberiuCristianLeon commited on
Commit
8128fc3
·
verified ·
1 Parent(s): f14d478

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -60,8 +60,21 @@ class Translators:
60
 
61
  def quickmt(self):
62
  from quickmt import Translator
 
 
 
 
 
 
 
 
 
 
 
 
63
  # Auto-detects GPU, set to "cpu" to force CPU inference
64
- translation = Translator(f"./quickmt-{self.sl}-{self.tl}/", device="auto")
 
65
  # Translate - set beam size to 1 for faster speed (but lower quality)
66
  return translation({self.input_text}, beam_size=5)
67
 
 
60
 
61
  def quickmt(self):
62
  from quickmt import Translator
63
+ from quickmt.hub import hf_download, hf_list
64
+ from pathlib import Path
65
+ input_model = f"quickmt-{self.sl}-{self.tl}"
66
+ model_path = Path("/code/models") / input_model
67
+ choices = [i.split("/")[1] for i in hf_list()]
68
+ print(choices)
69
+ if not model_path.exists():
70
+ hf_download(
71
+ model_name = f"quickmt/{input_model}",
72
+ output_dir=Path("/code/models") / input_model,
73
+ )
74
+ print(f"Loading model {input_model}")
75
  # Auto-detects GPU, set to "cpu" to force CPU inference
76
+ translation = Translator(str(model_path), device="auto", inter_threads=2)
77
+ # translation = Translator(f"./quickmt-{self.sl}-{self.tl}/", device="auto", inter_threads=2)
78
  # Translate - set beam size to 1 for faster speed (but lower quality)
79
  return translation({self.input_text}, beam_size=5)
80