Skip to content

Commit 8ec54d2

Browse files
authored
add custom_opt in REST server (#1817)
1 parent 0e143ff commit 8ec54d2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

onmt/translate/translation_server.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def start(self, config_file):
151151
'preprocess_opt': conf.get('preprocess', None),
152152
'tokenizer_opt': conf.get('tokenizer', None),
153153
'postprocess_opt': conf.get('postprocess', None),
154+
'custom_opt': conf.get('custom_opt', None),
154155
'on_timeout': conf.get('on_timeout', None),
155156
'model_root': conf.get('model_root', self.models_root),
156157
'ct2_model': conf.get('ct2_model', None)
@@ -245,10 +246,10 @@ class ServerModel(object):
245246
opt (dict): Options for the Translator
246247
model_id (int): Model ID
247248
preprocess_opt (list): Options for preprocess processus or None
248-
(extend for CJK)
249249
tokenizer_opt (dict): Options for the tokenizer or None
250250
postprocess_opt (list): Options for postprocess processus or None
251-
(extend for CJK)
251+
custom_opt (dict): Custom options, can be used within preprocess or
252+
postprocess, default None
252253
load (bool): whether to load the model during :func:`__init__()`
253254
timeout (int): Seconds before running :func:`do_timeout()`
254255
Negative values means no timeout
@@ -259,10 +260,11 @@ class ServerModel(object):
259260
"""
260261

261262
def __init__(self, opt, model_id, preprocess_opt=None, tokenizer_opt=None,
262-
postprocess_opt=None, load=False, timeout=-1,
263+
postprocess_opt=None, custom_opt=None, load=False, timeout=-1,
263264
on_timeout="to_cpu", model_root="./", ct2_model=None):
264265
self.model_root = model_root
265266
self.opt = self.parse_opt(opt)
267+
self.custom_opt = custom_opt
266268

267269
self.model_id = model_id
268270
self.preprocess_opt = preprocess_opt

requirements.opt.txt

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ cffi
22
torchvision
33
joblib
44
librosa
5+
numba==0.43.0
6+
llvmlite==0.32.1
57
Pillow
68
git+git://github.com/pytorch/audio.git@d92de5b97fc6204db4b1e3ed20c03ac06f5d53f0
79
pyrouge

0 commit comments

Comments
 (0)