Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -231,12 +231,12 @@ class Translators:
|
|
| 231 |
from quickmt import Translator
|
| 232 |
# 'auto' auto-detects GPU, set to "cpu" to force CPU inference
|
| 233 |
# device = 'gpu' if torch.cuda.is_available() else 'cpu'
|
| 234 |
-
translator = Translator(str(model_path))
|
| 235 |
# translation = Translator(f"./quickmt-{self.sl}-{self.tl}/", device="auto/cpu", intra_threads=2, inter_threads=2, compute_type="int8")
|
| 236 |
# set beam size to 1 for faster speed (but lower quality) device="auto/cpu/gpu"
|
| 237 |
# Options for compute_type: default, auto, int8, int8_float32, int8_float16, int8_bfloat16, int16, float16, bfloat16, float32
|
| 238 |
# "int8" will work well for inference on CPU and give "int8_float16" or "int8_bfloat16" a try for GPU inference.
|
| 239 |
-
translation = translator(input_text
|
| 240 |
# print(model_path, input_text, translation)
|
| 241 |
return translation
|
| 242 |
|
|
|
|
| 231 |
from quickmt import Translator
|
| 232 |
# 'auto' auto-detects GPU, set to "cpu" to force CPU inference
|
| 233 |
# device = 'gpu' if torch.cuda.is_available() else 'cpu'
|
| 234 |
+
translator = Translator(str(model_path), device="auto", compute_type="auto", beam_size=5, max_input_length = 512, max_decoding_length = 512)
|
| 235 |
# translation = Translator(f"./quickmt-{self.sl}-{self.tl}/", device="auto/cpu", intra_threads=2, inter_threads=2, compute_type="int8")
|
| 236 |
# set beam size to 1 for faster speed (but lower quality) device="auto/cpu/gpu"
|
| 237 |
# Options for compute_type: default, auto, int8, int8_float32, int8_float16, int8_bfloat16, int16, float16, bfloat16, float32
|
| 238 |
# "int8" will work well for inference on CPU and give "int8_float16" or "int8_bfloat16" a try for GPU inference.
|
| 239 |
+
translation = translator(input_text)
|
| 240 |
# print(model_path, input_text, translation)
|
| 241 |
return translation
|
| 242 |
|