TiberiuCristianLeon commited on
Commit
411987b
·
verified ·
1 Parent(s): 35cbe7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -63,24 +63,23 @@ class Translators:
63
  from quickmt.hub import hf_download
64
  from pathlib import Path
65
  model_name = f"quickmt-{self.sl}-{self.tl}"
66
- model_path = Path("/code/models") / model_name
67
- from quickmt.hub import hf_list
68
- choices = [i.split("/quickmt-")[1] for i in hf_list()]
69
- if f"{self.sl}-{self.tl}" not in choices:
 
 
 
 
 
 
70
  translation = f'Model {model_name} from {iso1_to_name[self.sl]} to {iso1_to_name[self.tl]} not available!'
71
- message = f"Available models: {', '.join(choices.sort())}"
72
  return translation, message
73
- models = ['zh-en', 'en-zh', 'fr-en', 'en-fr', 'de-en', 'en-de', 'ko-en',
74
- 'en-ko', 'en-ar', 'ar-en', 'ja-en', 'en-ja', 'it-en', 'en-it',
75
- 'hi-en', 'en-hi', 'en-es', 'es-en', 'ru-en', 'en-ru', 'pt-en',
76
- 'en-pt', 'bn-en', 'en-bn', 'id-en', 'en-id', 'fa-en', 'en-fa',
77
- 'vi-en', 'en-vi', 'tr-en', 'en-tr', 'ur-en', 'en-ur', 'en-hu',
78
- 'hu-en', 'th-en', 'en-th', 'el-en', 'en-el', 'pl-en', 'en-pl',
79
- 'en-lv', 'lv-en', 'cs-en', 'ro-en', 'en-ro', 'en-cs', 'he-en', 'en-he', 'da-en']
80
  if not model_path.exists():
81
  hf_download(
82
  model_name = f"quickmt/{model_name}",
83
- output_dir=Path("/code/models") / model_name,
84
  )
85
  # 'auto' auto-detects GPU, set to "cpu" to force CPU inference
86
  device = 'gpu' if torch.cuda.is_available() else 'cpu'
 
63
  from quickmt.hub import hf_download
64
  from pathlib import Path
65
  model_name = f"quickmt-{self.sl}-{self.tl}"
66
+ model_path = Path("/quickmt/models") / model_name
67
+ # from quickmt.hub import hf_list
68
+ # quickmt_models = [i.split("/quickmt-")[1] for i in hf_list()]
69
+ # quickmt_models.sort()
70
+ # print(quickmt_models)
71
+ quickmt_models = ['ar-en', 'bn-en', 'cs-en', 'da-en', 'de-en', 'el-en', 'en-ar', 'en-bn', 'en-cs', 'en-de', 'en-el', 'en-es',
72
+ 'en-fa', 'en-fr', 'en-he', 'en-hi', 'en-hu', 'en-id', 'en-it', 'en-ja', 'en-ko', 'en-lv', 'en-pl', 'en-pt',
73
+ 'en-ro', 'en-ru', 'en-th', 'en-tr', 'en-ur', 'en-vi', 'en-zh', 'es-en', 'fa-en', 'fr-en', 'he-en', 'hi-en',
74
+ 'hu-en', 'id-en', 'it-en', 'ja-en', 'ko-en', 'lv-en', 'pl-en', 'pt-en', 'ro-en', 'ru-en', 'th-en', 'tr-en', 'ur-en', 'vi-en', 'zh-en']
75
+ if f"{self.sl}-{self.tl}" not in quickmt_models:
76
  translation = f'Model {model_name} from {iso1_to_name[self.sl]} to {iso1_to_name[self.tl]} not available!'
77
+ message = f"Available models: {', '.join(quickmt_models)}"
78
  return translation, message
 
 
 
 
 
 
 
79
  if not model_path.exists():
80
  hf_download(
81
  model_name = f"quickmt/{model_name}",
82
+ output_dir=Path("/quickmt/models") / model_name,
83
  )
84
  # 'auto' auto-detects GPU, set to "cpu" to force CPU inference
85
  device = 'gpu' if torch.cuda.is_available() else 'cpu'