Skip to content

Commit

Permalink
update config
Browse files Browse the repository at this point in the history
  • Loading branch information
andy1xx8 committed Sep 8, 2021
1 parent e81bf56 commit c398c8f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions conf/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ downloader:

run_on_cpu: True
use_deblur_model: False
enhanced_output_only: False
deblur_model_path: "Deblurring/pretrained_models/model_deblurring.pth"
1 change: 1 addition & 0 deletions conf/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ downloader:
num_threads: 8
run_on_cpu: False
use_deblur_model: True
enhanced_output_only: False
deblur_model_path: "Deblurring/pretrained_models/model_deblurring.pth"
1 change: 1 addition & 0 deletions conf/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ downloader:

run_on_cpu: True
use_deblur_model: False
enhanced_output_only: False
deblur_model_path: "Deblurring/pretrained_models/model_deblurring.pth"
11 changes: 8 additions & 3 deletions enhance_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@

class EnhanceService:

def __init__(self, deblur_model_path, use_cpu: bool = True, use_deblur_model: bool = False):
def __init__(self,
deblur_model_path,
use_cpu: bool = True,
use_deblur_model: bool = False,
enhanced_output_only: bool = False,
):
self.use_cpu = use_cpu
self.use_deblur_model = use_deblur_model
self.enhanced_output_only = enhanced_output_only
# Executor to run enhance process concurrently
self.executor = ThreadPoolExecutor(max_workers=8)
# A downloader to download image using a thread pool with 16 threads
Expand Down Expand Up @@ -85,9 +91,8 @@ def _enhance_image(self, image, factor, out_dir) -> [str, float]:
img_output = self._process_white_balancing(restored)

restored = cv2.cvtColor(restored, cv2.COLOR_RGB2BGR)

origin_score, improved_score = self._calc_score([restored, img_output])
if origin_score > improved_score:
if origin_score > improved_score and self.enhanced_output_only:
img_output = restored

output_path = os.path.join(out_dir, f'{uuid.uuid1()}.jpg')
Expand Down
1 change: 0 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def setup_http_server(
threads=nthreads if nthreads is not None else 4
)


if __name__ == "__main__":
os.environ['APP_MODE'] = sys.argv[1] if len(sys.argv) > 1 else 'development'
setup_logging()
Expand Down

0 comments on commit c398c8f

Please sign in to comment.