From fe926db2666dc2e1e9662c53408079050671f539 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Thu, 1 Dec 2022 08:19:59 +0330 Subject: aligning images in the center, now checks whether models already exist before downloading --- magni.py | 16 ++++++++++++++-- template.jinja2 | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/magni.py b/magni.py index f1aaef9..dde17f7 100755 --- a/magni.py +++ b/magni.py @@ -95,6 +95,8 @@ def get_image_path() -> str: return image_path +# TODO-both models are garbage. should train models specifically +# for black and white pics. def espcn_superscaler(img): """ESPCN superscaler.""" superres = cv2.dnn_superres.DnnSuperResImpl_create() @@ -203,8 +205,18 @@ async def model_downloader() -> typing.Optional[ "https://github.com/Saafke/FSRCNN_Tensorflow/raw/master/models/FSRCNN_x2.pb", ] + url_list: typing.List[str] = [] + for model in down_list: + if ( + os.path.exists( + get_model_path() + "/" + model[model.rfind("/") + 1 :] + ) + is False + ): + url_list.append(model) + url_tag_list: typing.List[typing.Tuple[str, str]] = [] - for url in down_list: + for url in url_list: url_tag_list.append((url, url[url.rfind("/") + 1 :])) response_list: typing.Optional[ typing.List[typing.Tuple[requests.Response, str]] @@ -306,7 +318,7 @@ def serve(port: int) -> None: """Startup a simple http file server.""" handler = MagniHTTPRequestHandler - print("now servering on {}:{}".format("127.0.0.1", repr(port))) + print(f"now servering on 127.0.0.1:{repr(port)}") with socketserver.TCPServer(("", port), handler) as httpd: httpd.serve_forever() diff --git a/template.jinja2 b/template.jinja2 index e307b6b..1ba2f40 100644 --- a/template.jinja2 +++ b/template.jinja2 @@ -10,7 +10,7 @@

{% for image in image_list %} - + {% endfor %}

-- cgit v1.2.3