mirror of
https://github.com/qurator-spk/eynollah.git
synced 2026-07-26 05:29:16 +02:00
enhancement: log job timing here, too
This commit is contained in:
parent
0956daded9
commit
4298b021e9
1 changed files with 7 additions and 3 deletions
|
|
@ -3,9 +3,9 @@ Image enhancer. The output can be written as same scale of input or in new predi
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
import os
|
import os
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
|
|
@ -48,6 +48,8 @@ class Enhancer(Eynollah):
|
||||||
dir_out: Optional[str] = None,
|
dir_out: Optional[str] = None,
|
||||||
overwrite: bool = False,
|
overwrite: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
t0 = time.time()
|
||||||
|
self.logger.info(img_filename)
|
||||||
|
|
||||||
image = self.cache_images(image_filename=img_filename, image_pil=img_pil)
|
image = self.cache_images(image_filename=img_filename, image_pil=img_pil)
|
||||||
output_filename = os.path.join(dir_out or "", image['name'] + '.png')
|
output_filename = os.path.join(dir_out or "", image['name'] + '.png')
|
||||||
|
|
@ -67,6 +69,7 @@ class Enhancer(Eynollah):
|
||||||
|
|
||||||
cv2.imwrite(output_filename, img_res)
|
cv2.imwrite(output_filename, img_res)
|
||||||
self.logger.info("output filename: '%s'", output_filename)
|
self.logger.info("output filename: '%s'", output_filename)
|
||||||
|
self.logger.info("Job done in %.1fs", time.time() - t0)
|
||||||
|
|
||||||
def run(self,
|
def run(self,
|
||||||
overwrite: bool = False,
|
overwrite: bool = False,
|
||||||
|
|
@ -78,6 +81,7 @@ class Enhancer(Eynollah):
|
||||||
Enlarge and enhance the scanned images
|
Enlarge and enhance the scanned images
|
||||||
"""
|
"""
|
||||||
if dir_in:
|
if dir_in:
|
||||||
|
t0_tot = time.time()
|
||||||
ls_imgs = [os.path.join(dir_in, image_filename)
|
ls_imgs = [os.path.join(dir_in, image_filename)
|
||||||
for image_filename in filter(is_image_filename,
|
for image_filename in filter(is_image_filename,
|
||||||
os.listdir(dir_in))]
|
os.listdir(dir_in))]
|
||||||
|
|
@ -87,8 +91,8 @@ class Enhancer(Eynollah):
|
||||||
raise ValueError("run requires either a single image filename or a directory")
|
raise ValueError("run requires either a single image filename or a directory")
|
||||||
|
|
||||||
for img_filename in ls_imgs:
|
for img_filename in ls_imgs:
|
||||||
self.logger.info(img_filename)
|
|
||||||
|
|
||||||
self.run_single(img_filename,
|
self.run_single(img_filename,
|
||||||
dir_out=dir_out,
|
dir_out=dir_out,
|
||||||
overwrite=overwrite)
|
overwrite=overwrite)
|
||||||
|
if dir_in:
|
||||||
|
self.logger.info("All jobs done in %.1fs", time.time() - t0_tot)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue