Merge pull request #1 from nivkner/container

add support for running with Docker
This commit is contained in:
gguilt 2022-09-27 16:53:51 +03:00 committed by GitHub
commit 72efbba081
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 85 additions and 5 deletions

47
Dockerfile Normal file
View File

@ -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" ]

View File

@ -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
@ -362,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)

View File

@ -9,6 +9,28 @@ 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.
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

View File

@ -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