From 5a3ea33cfce1105a8128356a3787176ed84e261d Mon Sep 17 00:00:00 2001 From: Niv Kaminer Date: Fri, 9 Sep 2022 03:55:22 +0300 Subject: [PATCH 1/6] ignore Qt signals outside of GUI --- decensor.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/decensor.py b/decensor.py index 2ce2f6b..a65971a 100755 --- a/decensor.py +++ b/decensor.py @@ -28,6 +28,17 @@ except ImportError as e: print("\nIf pip doesn't work, try update through Anaconda") print("install Anaconda : https://www.anaconda.com/distribution/ \n") +""" +to allow decensoring in CLI, ignore all methods targeting Qt signals, +when they aren't initialized (i.e. when the class isn't created by the GUI) +""" +class IgnoreAll(object): + def __getattr__(self,attr): + return IgnoreAll() + + def __call__(self, *args, **kwargs): + return IgnoreAll() + class Decensor(QtCore.QThread): def __init__(self, parentThread = None, text_edit = None, text_cursor = None, ui_mode = None): super().__init__(parentThread) @@ -39,7 +50,7 @@ class Decensor(QtCore.QThread): self.decensor_input_original_path = args.decensor_input_original_path self.decensor_output_path = args.decensor_output_path - self.signals = None # Signals class will be given by progressWindow + self.signals = IgnoreAll() # Signals class will be given by progressWindow self.model = None self.warm_up = False From fa7ed4ebcb2c873af186fcd663073104a37c0aca Mon Sep 17 00:00:00 2001 From: Niv Kaminer Date: Fri, 9 Sep 2022 03:55:34 +0300 Subject: [PATCH 2/6] allow using program from CLI --- decensor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/decensor.py b/decensor.py index a65971a..50c1dca 100755 --- a/decensor.py +++ b/decensor.py @@ -373,7 +373,7 @@ class Decensor(QtCore.QThread): print("Decensored image. Returning it.") return output_img -# if __name__ == '__main__': - # decensor = Decensor() - # decensor.decensor_all_images_in_folder() +if __name__ == '__main__': + decensor = Decensor() + decensor.decensor_all_images_in_folder() # equivalent to decensor.start() (running as QtThread) From 052ae65984449171bb82855ff49b813dfbb0536a Mon Sep 17 00:00:00 2001 From: Niv Kaminer Date: Fri, 9 Sep 2022 03:56:13 +0300 Subject: [PATCH 3/6] downgrade tensorflow to version compatible with python3.7 --- requirements-cpu.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-cpu.txt b/requirements-cpu.txt index 3373310..1f60e98 100644 --- a/requirements-cpu.txt +++ b/requirements-cpu.txt @@ -17,7 +17,7 @@ shiboken2==5.13.0 six==1.12.0 tensorboard==1.14.0 tensorflow-estimator==1.14.0 -tensorflow==1.15.2 +tensorflow==1.14.0 termcolor==1.1.0 Werkzeug==0.15.5 wrapt==1.11.2 From 772f41c516f4869c858eb193547c363ad359e29e Mon Sep 17 00:00:00 2001 From: Niv Kaminer Date: Fri, 9 Sep 2022 03:57:51 +0300 Subject: [PATCH 4/6] add dockerfile --- Dockerfile | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b52db31 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,47 @@ +FROM debian:buster-slim + +ENV BUILD_PACKAGES="\ + build-essential \ + python3-dev \ + cmake \ + tcl-dev \ + xz-utils \ + zlib1g-dev \ + git \ + curl \ + pkg-config \ + unzip" \ + APT_PACKAGES="\ + ca-certificates \ + openssl \ + bash \ + graphviz \ + fonts-noto \ + libpng16-16 \ + libfreetype6 \ + libjpeg62-turbo \ + libgomp1 \ + libhdf5-dev \ + python3 \ + python3-pip" \ + LANG=C.UTF-8 + +# get system packages +RUN set -ex; \ + apt-get update -y; \ + apt-get install -y --no-install-recommends ${APT_PACKAGES}; \ + apt-get install -y --no-install-recommends ${BUILD_PACKAGES}; + + +# get python packages +COPY requirements-cpu.txt /opt/requirements-cpu.txt +RUN set -ex; \ + pip3 install -U wheel setuptools; \ + pip3 install -r /opt/requirements-cpu.txt; + +# get source code +COPY . /opt/DeepCreamPy + +WORKDIR /opt/DeepCreamPy + +ENTRYPOINT [ "/usr/bin/python3", "decensor.py" ] From d1de0535a5fb0be57687caadbaef2935d1092d81 Mon Sep 17 00:00:00 2001 From: Niv Kaminer Date: Fri, 9 Sep 2022 04:30:07 +0300 Subject: [PATCH 5/6] update documentation --- docs/INSTALLATION.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index 59def01..1cca7ea 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -9,6 +9,16 @@ If you want to run the code yourself, you can clone this repo and download the m If you want access to older models, see https://drive.google.com/open?id=1_A0xFeJhrqpmulA6cC-a7RxJoQOD2RKm. +## running the code using Docker + +Once the input images and model have been placed in `decensor_input` and `models` respectively, +the code can be run in the command line using docker (or Podman), to avoid managing dependencies manually, as follows: + +``` +docker build -t deepcreampy . +docker run --rm -v $(pwd)/models:/opt/DeepCreamPy/models -v $(pwd)/decensor_input:/opt/DeepCreamPy/decensor_input -v $(pwd)/decensor_output:/opt/DeepCreamPy/decensor_output deepcreampy +``` + ### Dependencies (for running the code yourself) - Python 3.6.7 - TensorFlow 1.14 From 0e00c6845b5397803637fcb9e470ee5a8d3bac1a Mon Sep 17 00:00:00 2001 From: Niv Kaminer Date: Thu, 22 Sep 2022 00:28:26 +0300 Subject: [PATCH 6/6] add changes for mosaics to documentation --- docs/INSTALLATION.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index 1cca7ea..4405d89 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -12,13 +12,25 @@ If you want access to older models, see https://drive.google.com/open?id=1_A0xFe ## running the code using Docker Once the input images and model have been placed in `decensor_input` and `models` respectively, -the code can be run in the command line using docker (or Podman), to avoid managing dependencies manually, as follows: +the code can be run in the command line using docker (or podman), to avoid managing dependencies manually. +to build the container image use the command: ``` docker build -t deepcreampy . +``` + +then to desensor bar censors run the following command: +``` docker run --rm -v $(pwd)/models:/opt/DeepCreamPy/models -v $(pwd)/decensor_input:/opt/DeepCreamPy/decensor_input -v $(pwd)/decensor_output:/opt/DeepCreamPy/decensor_output deepcreampy ``` +to desensor mosaics run the following command: +``` +docker run --rm -v $(pwd)/models:/opt/DeepCreamPy/models -v $(pwd)/decensor_input:/opt/DeepCreamPy/decensor_input -v $(pwd)/decensor_input_original:/opt/DeepCreamPy/decensor_input_original -v $(pwd)/decensor_output:/opt/DeepCreamPy/decensor_output deepcreampy --is_mosaic=true +``` + +the contents of `decensor_input` and `decensor_input_original` are explained in the [decensoring tutorial](USAGE.md). + ### Dependencies (for running the code yourself) - Python 3.6.7 - TensorFlow 1.14