Skip to content

Commit

Permalink
[Colorize] Adding the service & some minor repo fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
arturgontijo committed Apr 30, 2019
1 parent f53c2b7 commit f8a7b8a
Show file tree
Hide file tree
Showing 38 changed files with 942 additions and 46 deletions.
43 changes: 43 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,41 @@ jobs:
docker_etcd_host_folder: singnet/etcd/${SERVICE_NAME}/
docker_etcd_container_folder: opt/singnet/${CIRCLE_PROJECT_REPONAME}/${SERVICE_FOLDER}/etcd/

build-siggraph-colorization:
docker:
- image: circleci/python:3.6.6-node
working_directory: ~/singnet
environment:
SERVICE_NAME: siggraph-colorization
SERVICE_FOLDER: services/siggraph-colorization
SERVICE_RUN_COMMAND: bash -c "git pull;python3 run_colorize_service.py"
SERVICE_TEST_COMMAND: bash -c "sleep 10;python3 test_colorize_service.py auto"
steps:
- build_command:
docker_nvidia: true
docker_image_name: siggraph_colorization
docker_container_name: SIGGRAPH_COLORIZATION

deploy-siggraph-colorization:
docker:
- image: circleci/python:3.6.6-node
working_directory: ~/singnet
environment:
SERVICE_NAME: siggraph-colorization
SERVICE_FOLDER: services/siggraph-colorization
CERTS_FOLDER: singnet/.certs
SERVICE_RUN_COMMAND: bash -c "git pull;python3 run_colorize_service.py --ssl"
SERVICE_TEST_COMMAND: bash -c "sleep 10;python3 test_colorize_service.py auto"
SNETD_PORT_MAINNET: 7035
SNETD_PORT_ROPSTEN: 7085
steps:
- deploy_command:
docker_nvidia: true
docker_image_name: siggraph_colorization
docker_container_name: SIGGRAPH_COLORIZATION
docker_etcd_host_folder: singnet/etcd/${SERVICE_NAME}/
docker_etcd_container_folder: opt/singnet/${CIRCLE_PROJECT_REPONAME}/${SERVICE_FOLDER}/etcd/

build-yolov3-object-detection:
docker:
- image: circleci/python:3.6.6-node
Expand Down Expand Up @@ -454,6 +489,14 @@ workflows:
branches:
only: master

- build-siggraph-colorization
- deploy-siggraph-colorization:
requires:
- build-siggraph-colorization
filters:
branches:
only: master

- build-yolov3-object-detection
- deploy-yolov3-object-detection:
requires:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ config/
!/services/
**/etcd/
!/docs/assets/*.jpg
!/docs/assets/users_guide/*.jpg
!/docs/assets/users_guide/*.jpg
!/docs/assets/users_guide/*.png
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ 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)]
- [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.
```
@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,
}
```
- [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 @@ -74,5 +85,6 @@ Each service is licensed as followed:
- 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)
- s2vt-video-captioning - [Attribution 4.0 International (CC BY 4.0)](http://creativecommons.org/licenses/by/4.0/)
- siggraph-colorization - [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](https://github.com/satoshiiizuka/siggraph2016_colorization/blob/master/LICENSE)
- yolov3-object-detection - [Public domain](https://github.com/pjreddie/darknet/blob/master/LICENSE)
- zeta36-chess-alpha-zero - [MIT License](https://github.com/Zeta36/chess-alpha-zero/blob/master/LICENSE.txt)
Binary file added docs/assets/users_guide/carnaval.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 added 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 added docs/assets/users_guide/jucelino.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 added 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.
16 changes: 16 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ <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">zeta36-chess-alpha-zero</h4>
Expand Down
4 changes: 2 additions & 2 deletions docs/users_guide/cntk-image-recon.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ You can use this service from [SingularityNET DApp](http://beta.singularitynet.i

You can also call the service from SingularityNET CLI (`snet`).

Assuming that you have an open channel (`id: 0`) to this service:
Assuming that you have an open channel to this service:

```
$ snet client call 0 0.00000001 54.203.198.53:7004 flowers '{"model": "ResNet152", "img_path": "https://www.fiftyflowers.com/site_files/FiftyFlowers/Image/Product/Mini-Black-Eye-bloom-350_c7d02e72.jpg"}'
$ snet client call snet cntk-image-recon flowers '{"model": "ResNet152", "img_path": "https://www.fiftyflowers.com/site_files/FiftyFlowers/Image/Product/Mini-Black-Eye-bloom-350_c7d02e72.jpg"}'
...
Read call params from cmdline...
Expand Down
4 changes: 2 additions & 2 deletions docs/users_guide/i3d-video-action-recognition.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ You can use this service from [SingularityNET DApp](http://beta.singularitynet.i

You can also call the service from SingularityNET CLI (`snet`).

Assuming that you have an open channel (`id: 0`) to this service:
Assuming that you have an open channel to this service:

```
$ snet client call 0 0.00000001 54.203.198.53:7005 video_action_recon '{"model": "400", "url": "http://crcv.ucf.edu/THUMOS14/UCF101/UCF101/v_CricketShot_g04_c02.avi"}'
$ snet client call snet i3d-video-action-recognition video_action_recon '{"model": "400", "url": "http://crcv.ucf.edu/THUMOS14/UCF101/UCF101/v_CricketShot_g04_c02.avi"}'
...
Read call params from cmdline...
Expand Down
4 changes: 2 additions & 2 deletions docs/users_guide/object-detection-image-recon.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ You can use this service from [SingularityNET DApp](http://beta.singularitynet.i

You can also call the service from SingularityNET CLI (`snet`).

Assuming that you have an open channel (`id: 0`) to this service:
Assuming that you have an open channel to this service:

```
$ snet client call 0 0.00000001 54.203.198.53:7006 detect_recon '{"model_detect": "yolov3", "model_recon": "ResNet152", "img_path": "https://figopetinsurance.com/sites/default/files/styles/blog_detail/public/imagedogsman-and-dog-hiking-mountainsblog.jpg", "confidence": "0.5"}'
$ snet client call snet object-detection-image-recon detect_recon '{"model_detect": "yolov3", "model_recon": "ResNet152", "img_path": "https://figopetinsurance.com/sites/default/files/styles/blog_detail/public/imagedogsman-and-dog-hiking-mountainsblog.jpg", "confidence": "0.5"}'
...
Read call params from cmdline...
Expand Down
7 changes: 2 additions & 5 deletions docs/users_guide/places365-scene-recognition.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@ And returns as **output**:

You can call the `places365-scene-recognition` service by installing the [SingularityNET Cli](https://github.com/singnet/snet-cli) through its `snet client call` command. Assuming you have an open channel to this service:

1. Use its CHANNEL_ID (e.g.: `270`);
2. Specify a price in AGIs (e.g.: `0`, since its a free service);
3. Point to the endpoint at which this service's [SNET Daemon](https://github.com/singnet/snet-daemon) listens to the blockchain waiting for client calls: `54.203.198.53:7019`. You can obtain this and other information about registered services by running `snet service print_metadata ORGANIZATION SERVICE_NAME`.
4. Filling in the method and some input data as defined in the service's `.proto` file.
1. Fill in the method and some input data as defined in the service's `.proto` file.

Example call:
```
$ snet client call 270 0 54.203.198.53:7019 recognize_scene '{"input_image":"https://static1.squarespace.com/static/564783d5e4b077901c4bdc37/t/5a823d47c83025d76ac6ddae/1518484818865/Piccolo-104.jpg?format=1500w", "predict":"io, categories"}'
$ snet client call snet places365-scene-recognition recognize_scene '{"input_image":"https://static1.squarespace.com/static/564783d5e4b077901c4bdc37/t/5a823d47c83025d76ac6ddae/1518484818865/Piccolo-104.jpg?format=1500w", "predict":"io, categories"}'
...
data: "{\"io\": \"indoor\", \"categories\": \" 0.924 -> beauty_salon, 0.006 -> gymnasium/indoor, 0.005 -> clean_room, 0.005 -> biology_laboratory, 0.004 -> chemistry_lab,\"}"
```
Expand Down
4 changes: 2 additions & 2 deletions docs/users_guide/s2vt-video-captioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ You can use this service from [SingularityNET DApp](http://beta.singularitynet.i

You can also call the service from SingularityNET CLI (`snet`).

Assuming that you have an open channel (`id: 0`) to this service:
Assuming that you have an open channel to this service:

```
$ snet client call 0 0.00000001 54.203.198.53:7007 video_cap '{"url": "http://crcv.ucf.edu/THUMOS14/UCF101/UCF101/v_PlayingGuitar_g05_c01.avi", "start_time_sec": "0", "stop_time_sec": "0"}'
$ snet client call snet s2vt-video-captioning video_cap '{"url": "http://crcv.ucf.edu/THUMOS14/UCF101/UCF101/v_PlayingGuitar_g05_c01.avi", "start_time_sec": "0", "stop_time_sec": "0"}'
...
Read call params from cmdline...
Expand Down
81 changes: 81 additions & 0 deletions docs/users_guide/siggraph-colorization.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<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>

<!-- Bootstrap core CSS -->
<link href="../css/bootstrap.min.css" rel="stylesheet">

<!-- Custom styles for this template -->
<link href="../css/pricing.css" rel="stylesheet">
<link href="../css/style.css" rel="stylesheet">
</head>

<body>

<div class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 bg-white border-bottom shadow-sm">
<h5 class="my-0 mr-md-auto font-weight-normal">SingularityNET</h5>
<a class="btn btn-outline-primary" href="../index.html">User's Guide Hub</a>
</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>
<p class="lead">Service User's Guide</p>
</div>

<div class="container">
<div id="preview"> </div>
</div>

<footer class="pt-4 my-md-5 pt-md-5 border-top"></footer>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../js/jquery-slim.min.js"></script>
<script src="../js/popper.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/holder.min.js"></script>
<script>
Holder.addTheme('thumb', {
bg: '#55595c',
fg: '#eceeef',
text: 'Thumbnail'
});
</script>
<script type="text/javascript" src="../js/showdown.min.js"></script>
<script>
function Editor(preview) {
this.update = function () {
var rawFile = new XMLHttpRequest();
var allText = "# Fail!";
rawFile.open("GET", "siggraph-colorization.md", false);
rawFile.onreadystatechange = function ()
{
if(rawFile.readyState === 4)
{
if(rawFile.status === 200 || rawFile.status === 0)
{
allText = rawFile.responseText;
}
}
};
rawFile.send(null);
let converter = new showdown.Converter({ tables: true });
let html = converter.makeHtml(allText);
preview.innerHTML = converter.makeHtml(html);
};
this.update();
}
var $ = function (id) { return document.getElementById(id); };
new Editor($("preview"));
</script>
</body>
<script src="../js/bootstrap.min.js"></script>
</html>
61 changes: 61 additions & 0 deletions docs/users_guide/siggraph-colorization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
[issue-template]: ../../../issues/new?template=BUG_REPORT.md
[feature-template]: ../../../issues/new?template=FEATURE_REQUEST.md

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

# Let there be Color!

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

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.

### What’s the point?

The service can colorize grayscale images.

### How does it work?

The user must provide the following input in order to start the service and get a response:

Input:
- `img_input`: A grayscale image URL.

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

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 colorize '{"img_input": "https://snet-models.s3.amazonaws.com/bh/Colorize/carnaval.jpg"}'
[Base64 Image]
```

### What to expect from this service?

Input Image:

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


Response:

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


Input Image:

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


Response:

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

4 changes: 2 additions & 2 deletions docs/users_guide/yolov3-object-detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ You can use this service from [SingularityNET DApp](http://beta.singularitynet.i

You can also call the service from SingularityNET CLI (`snet`).

Assuming that you have an open channel (`id: 0`) to this service:
Assuming that you have an open channel to this service:

```
$ snet client call 0 0.00000001 54.203.198.53:7008 detect '{"model": "yolov3", "img_path": "https://hips.hearstapps.com/amv-prod-cad-assets.s3.amazonaws.com/images/media/51/2017-10best-lead-photo-672628-s-original.jpg", "confidence": "0.5"}'
$ snet client call snet yolov3-object-detection detect '{"model": "yolov3", "img_path": "https://hips.hearstapps.com/amv-prod-cad-assets.s3.amazonaws.com/images/media/51/2017-10best-lead-photo-672628-s-original.jpg", "confidence": "0.5"}'
...
Read call params from cmdline...
Expand Down
4 changes: 2 additions & 2 deletions docs/users_guide/zeta36-chess-alpha-zero.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ You can use this service from [SingularityNET DApp](http://beta.singularitynet.i

You can also call the service from SingularityNET CLI (`snet`).

Assuming that you have an open channel (`id: 0`) to this service:
Assuming that you have an open channel to this service:

```
$ snet client call 0 0.00000001 54.203.198.53:7077 play '{"uid": "my_uid","move": "c2c4"}'
$ snet client call snet zeta36-chess-alpha-zero play '{"uid": "my_uid","move": "c2c4"}'
response:
UID: my_uid
Expand Down
18 changes: 6 additions & 12 deletions services/cntk-image-recon/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[issue-template]: ../../../../../issues/new?template=BUG_REPORT.md
[feature-template]: ../../../../../issues/new?template=FEATURE_REQUEST.md

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

# CNTK Image Recognition

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

- [Python 3.6.5](https://www.python.org/downloads/release/python-365/)
- [Node 8+ w/npm](https://nodejs.org/en/download/)
- [SNET CLI](https://github.com/singnet/snet-cli)
- Pre-trained models (dogs and flowers)

### Development
Expand Down Expand Up @@ -125,19 +125,13 @@ Image (Link): https://cdn2-www.dogtime.com/assets/uploads/2011/01/file_22950_sta

Through SingularityNET (follow this [link](https://dev.singularitynet.io/tutorials/publish/) to learn how to publish a service and open a payment channel to be able to call it):

Assuming that you have an open channel (`id: 0`) to this service:
Assuming that you have an open channel to this service:

```
$ snet client call snet cntk-image-recon flowers '{"model": "ResNet152", "img_path": "https://www.fiftyflowers.com/site_files/FiftyFlowers/Image/Product/Mini-Black-Eye-bloom-350_c7d02e72.jpg"}'
...
Read call params from cmdline...
Calling service...
response:
delta_time: '1.5536'
top_5: '{1: ''98.93%: sunflower'', 2: ''00.64%: black-eyed susan'', 3: ''00.16%:
barbeton daisy'', 4: ''00.14%: oxeye daisy'', 5: ''00.03%: daffodil''}'
Price for this call will be 0.00000001 AGI (use -y to remove this warning). Proceed? (y/n): y
delta_time: "2.5509"
top_5: "{1: \'98.93%: sunflower\', 2: \'00.64%: black-eyed susan\', 3: \'00.16%: barbeton daisy\', 4: \'00.14%: oxeye daisy\', 5: \'00.03%: daffodil\'}"
```

## Contributing and Reporting Issues
Expand Down
Loading

0 comments on commit f8a7b8a

Please sign in to comment.