Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,12 +9,14 @@ model_list = [
|
|
9 |
"liam168/trans-opus-mt-en-zh"
|
10 |
]
|
11 |
|
|
|
|
|
12 |
# init
|
13 |
for model_name in model_list:
|
14 |
-
pipeline("translation_en_to_zh", model=model_name)
|
15 |
|
16 |
def translate(text, model_name):
|
17 |
-
pipe =
|
18 |
return pipe(text)[0]["translation_text"]
|
19 |
|
20 |
with gr.Blocks() as demo:
|
|
|
9 |
"liam168/trans-opus-mt-en-zh"
|
10 |
]
|
11 |
|
12 |
+
|
13 |
+
translation_pipelines = {}
|
14 |
# init
|
15 |
for model_name in model_list:
|
16 |
+
translation_pipelines[model_name] = pipeline("translation_en_to_zh", model=model_name)
|
17 |
|
18 |
def translate(text, model_name):
|
19 |
+
pipe = translation_pipelines[model_name]
|
20 |
return pipe(text)[0]["translation_text"]
|
21 |
|
22 |
with gr.Blocks() as demo:
|