Update app.py
Browse files
app.py
CHANGED
|
@@ -20,17 +20,14 @@ def translate_text(text,progress=gr.Progress(track_tqdm=True)):
|
|
| 20 |
output_dir=Path("/tmp") / MODEL_NAME,
|
| 21 |
)
|
| 22 |
try:
|
| 23 |
-
if t is None
|
| 24 |
-
print(f"Loading model {input.model()}")
|
| 25 |
t = Translator(
|
| 26 |
str(model_path),
|
| 27 |
device="auto",
|
| 28 |
inter_threads=2,
|
| 29 |
)
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
output = t([text], beam_size=1)
|
| 33 |
-
return output[0]
|
| 34 |
except:
|
| 35 |
return text
|
| 36 |
|
|
|
|
| 20 |
output_dir=Path("/tmp") / MODEL_NAME,
|
| 21 |
)
|
| 22 |
try:
|
| 23 |
+
if t is None:
|
|
|
|
| 24 |
t = Translator(
|
| 25 |
str(model_path),
|
| 26 |
device="auto",
|
| 27 |
inter_threads=2,
|
| 28 |
)
|
| 29 |
+
output = t([text], beam_size=1)
|
| 30 |
+
return output[0]
|
|
|
|
|
|
|
| 31 |
except:
|
| 32 |
return text
|
| 33 |
|