AItool commited on
Commit
5773990
·
verified ·
1 Parent(s): ce8dcbb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -78,12 +78,13 @@ def translate(input_text, source, target):
78
  target = target_lang_dict[target]
79
 
80
  try:
81
- model_id = f"Helsinki-NLP/opus-mt-{source}-{target}"
82
- pipe = pipeline("translation", model=model_id, device=-1) # CPU
83
- translation = pipe(input_text)
84
- return translation[0]['translation_text']
 
85
  except KeyError:
86
- return f"Error: Translation from {source_readable} to {target} is not supported"
87
 
88
  with st.container():
89
  st.header("Basque (EU) Euskera Multilingual Translator (Basque as the Starting Point)")
 
78
  target = target_lang_dict[target]
79
 
80
  try:
81
+ target = target_lang_dict[target]
82
+ model = f"Helsinki-NLP/opus-mt-{source}-{target}"
83
+ pipe = pipeline("translation", model=model)
84
+ translation = pipe(input_text)
85
+ return translation[0]['translation_text']
86
  except KeyError:
87
+ return f"Error: Translation from {source_readable} to {target} is not supported"
88
 
89
  with st.container():
90
  st.header("Basque (EU) Euskera Multilingual Translator (Basque as the Starting Point)")