Skip to content

Commit

Permalink
[deoldify] Adding DeOldify service.
Browse files Browse the repository at this point in the history
  • Loading branch information
arturgontijo committed Mar 24, 2020
1 parent 6ccfd85 commit 9934875
Show file tree
Hide file tree
Showing 27 changed files with 197 additions and 254 deletions.
52 changes: 29 additions & 23 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,28 @@ jobs:
infura-api-key: ${INFURA_API_KEY}
daemon-version: ${CI_SNETD_VERSION}
daemon-pk: ${PK_DEEPFAKES_FACESWAP}
deoldify-colorizer:
docker:
- image: circleci/python:3.6.6-node
steps:
- checkout
- ssh-deployment/deploy:
ssh-host: ${SSH_HOST_DEOLDIFY_COLORIZER}
ssh-user: ${SSH_USER_DEOLDIFY_COLORIZER}
service-dir: "services/deoldify-colorizer"
mainnet-port: "7084"
testnet-port: "7085"
run-command: "python3 run_colorize_service.py --ssl"
docker-test-files: "Dockerfile, requirements.txt"
docker-file-path: "services/deoldify-colorizer/Dockerfile"
docker-no-cache: true
docker-image: "deoldify_colorizer"
docker-container: "DEOLDIFY_COLORIZER"
docker-nvidia: true
docker-volumes: "-v ~/singnet/.certs:/opt/singnet/.certs"
infura-api-key: ${INFURA_API_KEY}
daemon-version: ${CI_SNETD_VERSION}
daemon-pk: ${PK_DEOLDIFY_COLORIZER}
i3d-video-action-recognition:
docker:
- image: circleci/python:3.6.6-node
Expand Down Expand Up @@ -158,28 +180,6 @@ jobs:
infura-api-key: ${INFURA_API_KEY}
daemon-version: ${CI_SNETD_VERSION}
daemon-pk: ${PK_S2VT_VIDEO_CAPTIONING}
siggraph-colorization:
docker:
- image: circleci/python:3.6.6-node
steps:
- checkout
- ssh-deployment/deploy:
ssh-host: ${SSH_HOST_SIGGRAPH_COLORIZATION}
ssh-user: ${SSH_USER_SIGGRAPH_COLORIZATION}
service-dir: "services/siggraph-colorization"
mainnet-port: "7084"
testnet-port: "7085"
run-command: "python3 run_colorize_service.py --ssl"
docker-test-files: "Dockerfile, requirements.txt"
docker-file-path: "services/siggraph-colorization/Dockerfile"
docker-no-cache: true
docker-image: "siggraph_colorization"
docker-container: "SIGGRAPH_COLORIZATION"
docker-nvidia: true
docker-volumes: "-v ~/singnet/.certs:/opt/singnet/.certs"
infura-api-key: ${INFURA_API_KEY}
daemon-version: ${CI_SNETD_VERSION}
daemon-pk: ${PK_SIGGRAPH_COLORIZATION}
sound-spleeter:
docker:
- image: circleci/python:3.6.6-node
Expand Down Expand Up @@ -256,6 +256,11 @@ jobs:
ssh-user: ${SSH_USER_CNTK_IMAGE_RECON}
test-command: "sleep 10;source '/cntk/activate-cntk';python3 test_image_recon_service.py auto"
docker-container: "CNTK_IMAGE_RECON"
- ssh-deployment/test:
ssh-host: ${SSH_HOST_DEOLDIFY_COLORIZER}
ssh-user: ${SSH_USER_DEOLDIFY_COLORIZER}
test-command: "sleep 10;python3 test_colorize_service.py auto"
docker-container: "DEOLDIFY_COLORIZER"
- ssh-deployment/test:
ssh-host: ${SSH_HOST_I3D_VIDEO_ACTION_RECON}
ssh-user: ${SSH_USER_I3D_VIDEO_ACTION_RECON}
Expand Down Expand Up @@ -302,18 +307,19 @@ workflows:
jobs:
- cntk-image-recon
# - deepfakes-faceswap
- deoldify-colorizer
- i3d-video-action-recognition
- places365-scene-recognition
- pneumonia-diagnosis
- real-time-voice-cloning
- s2vt-video-captioning
# - siggraph-colorization
- sound-spleeter
- yolov3-object-detection
- zeta36-chess-alpha-zero
- testing:
requires:
- cntk-image-recon
- deoldify-colorizer
- i3d-video-action-recognition
- places365-scene-recognition
- pneumonia-diagnosis
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "services/deoldify-colorizer/DeOldify"]
path = services/deoldify-colorizer/DeOldify
url = https://github.com/jantic/DeOldify
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,7 @@ For more details on how to publish and test a service, select it from the list b
### Images:
- [cntk-image-recon](services/cntk-image-recon) ([User's Guide](docs/users_guide/cntk-image-recon.md)) - This service uses ResNet152 model, trained to recognize different types of flowers and dog breeds. [[Reference](https://cntk.ai/pythondocs/CNTK_301_Image_Recognition_with_Deep_Transfer_Learning.html)]
- [deepfakes-faceswap](services/deepfakes-faceswap) ([User's Guide](docs/users_guide/deepfakes-faceswap.md)) - This service uses the Deepfakes Faceswap, trained on two input videos A and B, to perform face swapping on videos. [[Reference](https://github.com/deepfakes/faceswap)]
- [siggraph-colorization](services/siggraph-colorization) ([User's Guide](docs/users_guide/siggraph-colorization.md)) - This service learns to automatically color grayscale images with a deep network. [[Reference](http://iizuka.cs.tsukuba.ac.jp/projects/colorization/en/)]
```
@Article{IizukaSIGGRAPH2016,
author = {Satoshi Iizuka and Edgar Simo-Serra and Hiroshi Ishikawa},
title = {{Let there be Color!: Joint End-to-end Learning of Global and Local Image Priors for Automatic Image Colorization with Simultaneous Classification}},
journal = "ACM Transactions on Graphics (Proc. of SIGGRAPH 2016)",
year = 2016,
volume = 35,
number = 4,
}
```
- [deoldify-colorizer](services/deoldify-colorizer) ([User's Guide](docs/users_guide/deoldify-colorizer.md)) - This service colorizes grayscale images using an AI model. [[Reference](https://github.com/jantic/DeOldify)]
- [yolov3-object-detection](services/yolov3-object-detection) ([User's Guide](docs/users_guide/yolov3-object-detection.md)) - This service uses YOLOv3 model to detect objects on images. [[Reference](https://pjreddie.com/darknet/yolo/)]
```
@article{yolov3,
Expand Down Expand Up @@ -101,6 +91,7 @@ Each service is licensed as followed:
- cntk-image-recon - [MIT License](https://github.com/Microsoft/CNTK/blob/master/LICENSE.md)
- deepfakes-faceswap - [GPL-3.0](https://github.com/deepfakes/faceswap/blob/master/LICENSE)
- deoldify-colorizer - [MIT License](https://github.com/jantic/DeOldify/blob/master/LICENSE)
- i3d-video-action-recognition - [Apache License 2.0](https://github.com/deepmind/kinetics-i3d/blob/master/LICENSE)
- places365-scene-recognition - [MIT License](https://github.com/CSAILVision/places365/blob/master/LICENSE)
- pneumonia-diagnosis - [Attribution 4.0 International (CC BY 4.0)](https://creativecommons.org/licenses/by/4.0/)
Expand Down
Binary file modified docs/assets/users_guide/carnaval_colorized.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/users_guide/jucelino_colorized.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 15 additions & 15 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,21 @@ <h1 class="card-title pricing-card-title">Free</h1>
</div>
</div>

<!-- <div class="card mb-4 shadow-sm">-->
<!-- <div class="card-header">-->
<!-- <h4 class="my-0 font-weight-normal">siggraph-colorization</h4>-->
<!-- </div>-->
<!-- <div class="card-body">-->
<!-- <h1 class="card-title pricing-card-title">Free</h1>-->
<!-- <ul class="list-unstyled mt-3 mb-4">-->
<!-- <li>Gray Scale</li>-->
<!-- <li>Colorization</li>-->
<!-- <li>DNN</li>-->
<!-- <li><a href="http://iizuka.cs.tsukuba.ac.jp/projects/colorization/en/">Reference</a></li>-->
<!-- </ul>-->
<!-- <a href="users_guide/siggraph-colorization.html" class="btn btn-lg btn-block btn-outline-primary" role="button">User's Guide</a>-->
<!-- </div>-->
<!-- </div>-->
<div class="card mb-4 shadow-sm">
<div class="card-header">
<h4 class="my-0 font-weight-normal">deoldify-colorizer</h4>
</div>
<div class="card-body">
<h1 class="card-title pricing-card-title">Free</h1>
<ul class="list-unstyled mt-3 mb-4">
<li>Gray Scale</li>
<li>Colorization</li>
<li>DNN</li>
<li><a href="https://github.com/jantic/DeOldify">Reference</a></li>
</ul>
<a href="users_guide/deoldify-colorizer.html" class="btn btn-lg btn-block btn-outline-primary" role="button">User's Guide</a>
</div>
</div>

<div class="card mb-4 shadow-sm">
<div class="card-header">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="author" content="">
<link rel="shortcut icon" href="https://singularitynet.io/wp-content/uploads/2018/05/favicon.ico" />

<title>SingularityNET Service - siggraph-colorization</title>
<title>SingularityNET Service - deoldify-colorizer</title>

<!-- Bootstrap core CSS -->
<link href="../css/bootstrap.min.css" rel="stylesheet">
Expand All @@ -25,7 +25,7 @@ <h5 class="my-0 mr-md-auto font-weight-normal">SingularityNET</h5>
</div>

<div class="pricing-header px-3 py-3 pt-md-5 pb-md-4 mx-auto text-center">
<h1 class="display-4">siggraph-colorization</h1>
<h1 class="display-4">deoldify-colorizer</h1>
<p class="lead">Service User's Guide</p>
</div>

Expand Down Expand Up @@ -55,7 +55,7 @@ <h1 class="display-4">siggraph-colorization</h1>
this.update = function () {
var rawFile = new XMLHttpRequest();
var allText = "# Fail!";
rawFile.open("GET", "siggraph-colorization.md", false);
rawFile.open("GET", "deoldify-colorizer.md", false);
rawFile.onreadystatechange = function ()
{
if(rawFile.readyState === 4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

![singnetlogo](../assets/singnet-logo.jpg?raw=true 'SingularityNET')

# Let there be Color!
# DeOldify

This service uses [Let there be Color!](http://iizuka.cs.tsukuba.ac.jp/projects/colorization/en/) to perform colorization on grayscale images.
This service uses [DeOldify](https://github.com/jantic/DeOldify) to perform automatic image colorization.

It is part of our third party [DNN Model Services](https://github.com/singnet/dnn-model-services).

### Welcome

The service receives a grayscale image and uses it as an input for a pre-trained Torch model.

The model was trained on the [Places dataset](http://places.csail.mit.edu/) and thus best performance is for natural outdoor images.
The model was trained on the [ImageNet](http://www.image-net.org/download-images).

### What’s the point?

Expand All @@ -25,6 +25,7 @@ The user must provide the following input in order to start the service and get

Input:
- `img_input`: A grayscale image URL.
- `render_factor`: An integer factor between 7 and 45 (`default: 35`).

You can use this service from [SingularityNET DApp](http://beta.singularitynet.io/).

Expand All @@ -33,7 +34,7 @@ You can also call the service from SingularityNET CLI (`snet`).
Assuming that you have an open channel to this service:

```
$ snet client call snet siggraph-colorization default_group colorize '{"img_input": "https://snet-models.s3.amazonaws.com/bh/Colorize/carnaval.jpg"}'
$ snet client call snet deoldify-colorizer default_group colorize '{"img_input": "https://snet-models.s3.amazonaws.com/bh/Colorize/carnaval.jpg"}'
[Base64 Image]
```
Expand All @@ -54,8 +55,11 @@ Input Image:

![Carnaval Grayscale](../assets/users_guide/jucelino.png)


Response:

![BackpackManDog Splash 1](../assets/users_guide/jucelino_colorized.png)

Response (using `render_factor: 10`):

![BackpackManDog Splash 1](../assets/users_guide/jucelino_colorized_10.png)

1 change: 1 addition & 0 deletions services/deoldify-colorizer/DeOldify
Submodule DeOldify added at 3dde8a
51 changes: 51 additions & 0 deletions services/deoldify-colorizer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM pytorch/pytorch:1.4-cuda10.1-cudnn7-runtime

ARG git_owner="singnet"
ARG git_repo="dnn-model-services"
ARG git_branch="master"
ARG snetd_version

ENV SINGNET_REPOS=/opt/singnet
ENV DNN_REPO_NAME=${git_repo}
ENV SERVICES_FOLDER=${SINGNET_REPOS}/${DNN_REPO_NAME}/services
ENV SERVICE_NAME=deoldify-colorizer

RUN mkdir -p ${SINGNET_REPOS}

RUN apt-get update && \
apt-get install -y \
git \
wget \
nano \
curl

# OpenCV dependencies
RUN apt-get install -y libglib2.0-0 libsm6 libxext6 libxrender-dev

# Installing SNET Daemon
RUN SNETD_GIT_VERSION=`curl -s https://api.github.com/repos/singnet/snet-daemon/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")' || echo "v3.1.3"` && \
SNETD_VERSION=${snetd_version:-${SNETD_GIT_VERSION}} && \
cd /tmp && \
wget https://github.com/singnet/snet-daemon/releases/download/${SNETD_VERSION}/snet-daemon-${SNETD_VERSION}-linux-amd64.tar.gz && \
tar -xvf snet-daemon-${SNETD_VERSION}-linux-amd64.tar.gz && \
mv snet-daemon-${SNETD_VERSION}-linux-amd64/snetd /usr/bin/snetd

# Cloning service repository, downloading models
RUN cd ${SINGNET_REPOS} && \
git clone -b ${git_branch} https://github.com/${git_owner}/${DNN_REPO_NAME}.git && \
cd ${DNN_REPO_NAME}/utils && \
./get_colorize_model.sh

# DeOldify Repository
RUN cd ${SINGNET_DIR}/${SERVICE_NAME} && \
git submodule update --init -- DeOldify && \
cd DeOldify && \
pip install -r requirements.txt

# Building protobuf messages
RUN cd ${SERVICES_FOLDER}/${SERVICE_NAME} && \
pip install -U pip && \
pip install -r requirements.txt && \
sh buildproto.sh

WORKDIR ${SERVICES_FOLDER}/${SERVICE_NAME}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

![singnetlogo](../../docs/assets/singnet-logo.jpg 'SingularityNET')

# Let there be Color!
# DeOldify

This service uses [siggraph2016_colorization](http://iizuka.cs.tsukuba.ac.jp/projects/colorization/en/) to perform
automatic image colorization with simultaneous classification.
This service uses [DeOldify](https://github.com/jantic/DeOldify) to perform automatic image colorization.

It is part of our third party [DNN Model Services](https://github.com/singnet/dnn-model-services).

Expand All @@ -16,7 +15,7 @@ It is part of our third party [DNN Model Services](https://github.com/singnet/dn

- [Python 3.6.5](https://www.python.org/downloads/release/python-365/)
- [SNET CLI](https://github.com/singnet/snet-cli)
- Pre-trained model (`colornet.t7`)
- Pre-trained model (`ColorizeArtistic_gen.pth`)

### Development

Expand All @@ -27,11 +26,12 @@ $ git clone https://github.com/singnet/dnn-model-services.git
$ cd dnn-model-services/utils
$ ./get_colorize_model.sh
$ ls -la Resources/Models
total 678421
drwxrwxr-x 2 user user 4096 Apr 25 08:49 .
drwxrwxr-x 3 user user 4096 Apr 25 08:49 ..
-rw-r--r-- 1 root root 694703608 Apr 22 2016 colornet.t7
$ cd ../services/cntk-image-recon
total 249188
drwxrwxr-x 2 ci ci 4096 Mar 24 13:30 ./
drwxrwxr-x 5 ci ci 4096 Mar 24 13:29 ../
-rw-rw-r-- 1 ci ci 255144681 Mar 24 13:30 ColorizeArtistic_gen.pth
-rw-rw-r-- 1 ci ci 9210 Mar 24 13:30 watermark.png
$ cd ../services/deoldify-colorizer
```

### Running the service:
Expand Down Expand Up @@ -63,13 +63,13 @@ For example (using the Ropsten testnet):
```
$ cat snetd.config.json
{
"DAEMON_END_POINT": "0.0.0.0:7054",
"DAEMON_END_POINT": "0.0.0.0:7085",
"IPFS_END_POINT": "http://ipfs.singularitynet.io:80",
"BLOCKCHAIN_NETWORK_SELECTED": "ropsten",
"PASSTHROUGH_ENABLED": true,
"PASSTHROUGH_ENDPOINT": "http://localhost:7003",
"ORGANIZATION_ID": "snet",
"SERVICE_ID": "siggraph-colorization",
"SERVICE_ID": "deoldify-colorizer",
"LOG": {
"LEVEL": "debug",
"OUTPUT": {
Expand Down Expand Up @@ -115,7 +115,7 @@ Through SingularityNET (follow this [link](https://dev.singularitynet.io/tutoria
Assuming that you have an open channel to this service:

```
$ snet client call snet siggraph-colorization default_group colorize '{"img_input": "https://snet-models.s3.amazonaws.com/bh/Colorize/carnaval.jpg"}'
$ snet client call snet deoldify-colorizer default_group colorize '{"img_input": "https://snet-models.s3.amazonaws.com/bh/Colorize/carnaval.jpg"}'
[Base64 Image]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from service import registry

logging.basicConfig(level=10, format="%(asctime)s - [%(levelname)8s] - %(name)s - %(message)s")
log = logging.getLogger("run_siggraph_colorization_service")
log = logging.getLogger("run_colorization_service")


def main():
Expand All @@ -23,7 +23,7 @@ def main():
root_path = pathlib.Path(__file__).absolute().parent

# All services modules go here
service_modules = ["service.siggraph_colorization_service"]
service_modules = ["service.colorization_service"]

# Call for all the services listed in service_modules
all_p = start_all_services(root_path, service_modules, args.run_daemon, args.run_ssl)
Expand Down
5 changes: 5 additions & 0 deletions services/deoldify-colorizer/service/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
registry = {
"colorization_service": {
"grpc": 7003,
},
}
Loading

0 comments on commit 9934875

Please sign in to comment.