mirror of
https://github.com/qurator-spk/eynollah.git
synced 2026-07-11 22:29:29 +02:00
predictor for OCR models: work around ONNX bug …
(ONNX converted models already return `np.dtype=object` arrays of `np.str_` instead of `np.bytes_`; so undo this)
This commit is contained in:
parent
948d841a7d
commit
01e69a0e22
1 changed files with 4 additions and 0 deletions
|
|
@ -195,6 +195,10 @@ class Predictor(mp.context.SpawnProcess):
|
|||
# convert tf.string/np.object to fixed-length bytes
|
||||
# (because object segfaults in shm)
|
||||
if x.dtype is np.dtype(object):
|
||||
# ONNX conversion for some reason decodes bytes into str already
|
||||
# so here we undo this, too
|
||||
if x[0].dtype is np.dtype(object) and isinstance(x[0, 0], str):
|
||||
x = np.char.encode(x.astype(str), 'utf-8')
|
||||
return x.astype(bytes)
|
||||
return x
|
||||
if isinstance(result, (list, tuple)):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue