mirror of
https://github.com/qurator-spk/eynollah.git
synced 2026-07-26 05:29:16 +02:00
ocr: ensure forked logging handlers also work under pytest
This commit is contained in:
parent
79a9bb0128
commit
4f7c5675fc
3 changed files with 11 additions and 6 deletions
|
|
@ -51,7 +51,7 @@ def _run_single(*args, **kwargs):
|
|||
logq = kwargs.pop('logq')
|
||||
# replace all inherited handlers with queue handler
|
||||
logging.root.handlers.clear()
|
||||
_instance.logger.handlers.clear()
|
||||
_instance.logger.parent.handlers.clear()
|
||||
handler = logging.handlers.QueueHandler(logq)
|
||||
logging.root.addHandler(handler)
|
||||
return _instance.run_single(*args, **kwargs)
|
||||
|
|
@ -494,7 +494,9 @@ class Eynollah_ocr(Eynollah):
|
|||
for job in as_completed(list(jobs)):
|
||||
img_filename, logq = jobs[job]
|
||||
loglistener = logging.handlers.QueueListener(
|
||||
logq, *self.logger.handlers, respect_handler_level=False)
|
||||
logq, *self.logger.handlers,
|
||||
*self.logger.parent.handlers,
|
||||
respect_handler_level=False)
|
||||
try:
|
||||
loglistener.start()
|
||||
job.result()
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ MODEL_VRAM_LIMITS = {
|
|||
"region_fl_np": 1756,
|
||||
"table": 1818,
|
||||
"reading_order": 632,
|
||||
"ocr": 2400, # 850 for bs 8
|
||||
"ocr": 2600, # 850 for bs 8
|
||||
}
|
||||
|
||||
class EynollahModelZoo:
|
||||
|
|
@ -390,7 +390,9 @@ class EynollahModelZoo:
|
|||
if isinstance(provider0, tuple):
|
||||
provider0 = provider0[0]
|
||||
self.logger.info("using %s with ONNX provider %s for model %s",
|
||||
"GPU %d" % gpu if gpu >= 0 else "CPU",
|
||||
"GPU %d" % gpu if (gpu >= 0 and not
|
||||
provider0.startswith("CPU"))
|
||||
else "CPU",
|
||||
provider0[:-17], model_category)
|
||||
model = ort.InferenceSession(
|
||||
model_path,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ def test_run_eynollah_ocr_filename(
|
|||
'-o', str(outfile.parent),
|
||||
] + options,
|
||||
[
|
||||
'output filename:'
|
||||
str(infile)
|
||||
]
|
||||
)
|
||||
assert outfile.exists()
|
||||
|
|
@ -57,7 +57,8 @@ def test_run_eynollah_ocr_directory(
|
|||
'-o', str(outdir),
|
||||
],
|
||||
[
|
||||
'output filename:'
|
||||
'Job done in',
|
||||
'All jobs done in',
|
||||
]
|
||||
)
|
||||
assert len(list(outdir.iterdir())) == 2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue