Manga Colorization

Black&White manga/comic colorization, based on pix2pix.

Prerequests: Python 3, GPU # This notebook was tested in datahub

In [1]:
! git clone https://github.com/glh3025/ml-art-project4.git
Cloning into 'ml-art-project4'...
remote: Enumerating objects: 274, done.
remote: Counting objects: 100% (274/274), done.
remote: Compressing objects: 100% (262/262), done.
remote: Total 274 (delta 10), reused 268 (delta 7), pack-reused 0
Receiving objects: 100% (274/274), 37.50 MiB | 33.83 MiB/s, done.
Resolving deltas: 100% (10/10), done.
Checking out files: 100% (243/243), done.
In [2]:
cd ml-art-project4
/datasets/home/home-03/75/075/lgong/ml-art-project4
In [3]:
! pip install -r requirements.txt
The directory '/home/jovyan/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/jovyan/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: torch>=0.4.1 in /opt/conda/lib/python3.6/site-packages (from -r requirements.txt (line 1)) (1.0.1.post2)
Requirement already satisfied: torchvision>=0.2.1 in /opt/conda/lib/python3.6/site-packages (from -r requirements.txt (line 2)) (0.2.1)
Requirement already satisfied: dominate>=2.3.1 in /datasets/home/home-03/75/075/lgong/.local/lib/python3.6/site-packages (from -r requirements.txt (line 3)) (2.3.5)
Requirement already satisfied: visdom>=0.1.8.3 in /datasets/home/home-03/75/075/lgong/.local/lib/python3.6/site-packages (from -r requirements.txt (line 4)) (0.1.8.8)
Requirement already satisfied: numpy in /opt/conda/lib/python3.6/site-packages (from torchvision>=0.2.1->-r requirements.txt (line 2)) (1.15.4)
Requirement already satisfied: pillow>=4.1.1 in /opt/conda/lib/python3.6/site-packages (from torchvision>=0.2.1->-r requirements.txt (line 2)) (5.4.1)
Requirement already satisfied: six in /opt/conda/lib/python3.6/site-packages (from torchvision>=0.2.1->-r requirements.txt (line 2)) (1.12.0)
Requirement already satisfied: scipy in /opt/conda/lib/python3.6/site-packages (from visdom>=0.1.8.3->-r requirements.txt (line 4)) (1.1.0)
Requirement already satisfied: requests in /opt/conda/lib/python3.6/site-packages (from visdom>=0.1.8.3->-r requirements.txt (line 4)) (2.12.4)
Requirement already satisfied: tornado in /opt/conda/lib/python3.6/site-packages (from visdom>=0.1.8.3->-r requirements.txt (line 4)) (5.1.1)
Requirement already satisfied: pyzmq in /opt/conda/lib/python3.6/site-packages (from visdom>=0.1.8.3->-r requirements.txt (line 4)) (17.1.2)
Requirement already satisfied: torchfile in /datasets/home/home-03/75/075/lgong/.local/lib/python3.6/site-packages (from visdom>=0.1.8.3->-r requirements.txt (line 4)) (0.1.0)
Requirement already satisfied: websocket-client in /datasets/home/home-03/75/075/lgong/.local/lib/python3.6/site-packages (from visdom>=0.1.8.3->-r requirements.txt (line 4)) (0.56.0)
In [4]:
! wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
--2019-05-30 23:08:41--  https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
Resolving web.ucsd.edu (web.ucsd.edu)... 132.239.1.231, 132.239.1.230
Connecting to web.ucsd.edu (web.ucsd.edu)|132.239.1.231|:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 16648024 (16M) [application/octet-stream]
Saving to: ‘ngrok-stable-linux-amd64.zip’

ngrok-stable-linux- 100%[===================>]  15.88M  13.8MB/s    in 1.1s    

2019-05-30 23:08:42 (13.8 MB/s) - ‘ngrok-stable-linux-amd64.zip’ saved [16648024/16648024]

In [5]:
! unzip ngrok-stable-linux-amd64.zip
Archive:  ngrok-stable-linux-amd64.zip
  inflating: ngrok                   
In [6]:
# Let Visdom run background, 8097 is the default output port of pix2pix model.
get_ipython().system_raw('python3 -m visdom.server -port 8097 >> visdomlog.txt 2>&1 &')
In [7]:
get_ipython().system_raw('./ngrok http 8097 &')
In [8]:
# Click the link below to access Visdom.
! curl -s http://localhost:4040/api/tunnels | python3 -c \
    "import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])"
https://af7e1d8d.ngrok.io
In [9]:
# Make B&W images from colored ones to save some time

import os
import numpy as np
import cv2
import argparse

data_dir_A = "datasets/onepiece/A/"
data_dir_B = "datasets/onepiece/B/"
data_dir_AB = "datasets/onepiece_AB/"

splits = os.listdir(data_dir_A)

for sp in splits:
    img_fold_A = os.path.join(data_dir_A, sp)
    img_fold_B = os.path.join(data_dir_B, sp)
    if not os.path.isdir(img_fold_B):
        os.makedirs(img_fold_B)
    img_list = os.listdir(img_fold_A)
    num_imgs = len(img_list)
    print('split = %s, use %d/%d images' % (sp, num_imgs, len(img_list)))
    img_fold_AB = os.path.join(data_dir_AB, sp)
    if not os.path.isdir(img_fold_AB):
        os.makedirs(img_fold_AB)
    print('split = %s, number of images = %d' % (sp, num_imgs))
    for n in range(num_imgs):
        name_A = img_list[n]
        path_A = os.path.join(img_fold_A, name_A)
        name_B = name_A
        path_B = os.path.join(img_fold_B, name_B)
        
        if os.path.isfile(path_A):# and os.path.isfile(path_B):
            name_AB = name_A
            path_AB = os.path.join(img_fold_AB, name_AB)
            im_A = cv2.imread(path_A, 1) # python2: cv2.CV_LOAD_IMAGE_COLOR; python3: cv2.IMREAD_COLOR
#             im_B = cv2.imread(path_B, 1) # python2: cv2.CV_LOAD_IMAGE_COLOR; python3: cv2.IMREAD_COLOR
            im_B = cv2.cvtColor(im_A, cv2.COLOR_BGR2GRAY)
            cv2.imwrite(path_B, im_B)
#             im_AB = np.concatenate([im_A, im_B], 1)
#             cv2.imwrite(path_AB, im_AB)
split = val, use 28/28 images
split = val, number of images = 28
split = test, use 8/8 images
split = test, number of images = 8
split = train, use 141/141 images
split = train, number of images = 141
In [19]:
# If use my pretrained model, download from
https://drive.google.com/file/d/1BcPpAf7FpQ9hO6LiDeYd086UQ3cybden/view?usp=sharing
# and set path ./checkpoints/color_pix2pix/latest_net_G.pth
/bin/sh: 1: w3m: not found
In [10]:
# Train model using ~150 onepiece pages. More pages will be better.
# modified generator model to Unet512 to get higher resolution image.
# By default will train 200 epochs, but ~20 epochs is enough for me.
! python train.py --dataroot ./datasets/onepiece/A/ --name color_pix2pix --model colorization --netG unet_512 --load_size 568 --crop_size 512
----------------- Options ---------------
               batch_size: 1                             
                    beta1: 0.5                           
          checkpoints_dir: ./checkpoints                 
           continue_train: False                         
                crop_size: 512                           	[default: 256]
                 dataroot: ./datasets/onepiece/A/        	[default: None]
             dataset_mode: colorization                  
                direction: AtoB                          
              display_env: main                          
             display_freq: 400                           
               display_id: 1                             
            display_ncols: 4                             
             display_port: 8097                          
           display_server: http://localhost              
          display_winsize: 256                           
                    epoch: latest                        
              epoch_count: 1                             
                 gan_mode: vanilla                       
                  gpu_ids: 0                             
                init_gain: 0.02                          
                init_type: normal                        
                 input_nc: 1                             
                  isTrain: True                          	[default: None]
                lambda_L1: 100.0                         
                load_iter: 0                             	[default: 0]
                load_size: 568                           	[default: 286]
                       lr: 0.0002                        
           lr_decay_iters: 50                            
                lr_policy: linear                        
         max_dataset_size: inf                           
                    model: colorization                  	[default: cycle_gan]
               n_layers_D: 3                             
                     name: color_pix2pix                 	[default: experiment_name]
                      ndf: 64                            
                     netD: basic                         
                     netG: unet_512                      	[default: unet_256]
                      ngf: 64                            
                    niter: 100                           
              niter_decay: 100                           
               no_dropout: False                         
                  no_flip: False                         
                  no_html: False                         
                     norm: batch                         
              num_threads: 4                             
                output_nc: 2                             
                    phase: train                         
                pool_size: 0                             
               preprocess: resize_and_crop               
               print_freq: 100                           
             save_by_iter: False                         
          save_epoch_freq: 5                             
         save_latest_freq: 5000                          
           serial_batches: False                         
                   suffix:                               
         update_html_freq: 1000                          
                  verbose: False                         
----------------- End -------------------
dataset [ColorizationDataset] was created
The number of training images = 177
initialize network with normal
initialize network with normal
model [ColorizationModel] was created
---------- Networks initialized -------------
[Network G] Total number of parameters : 66.995 M
[Network D] Total number of parameters : 2.766 M
-----------------------------------------------
WARNING:root:Setting up a new session...
create web directory ./checkpoints/color_pix2pix/web...
(epoch: 1, iters: 100, time: 0.259, data: 0.923) G_GAN: 1.356 G_L1: 8.928 D_real: 0.764 D_fake: 0.394 
End of epoch 1 / 200 	 Time Taken: 42 sec
learning rate = 0.0002000
(epoch: 2, iters: 23, time: 0.268, data: 0.001) G_GAN: 1.989 G_L1: 6.721 D_real: 0.173 D_fake: 0.201 
(epoch: 2, iters: 123, time: 0.254, data: 0.004) G_GAN: 1.507 G_L1: 11.347 D_real: 0.464 D_fake: 0.429 
End of epoch 2 / 200 	 Time Taken: 39 sec
learning rate = 0.0002000
/opt/conda/lib/python3.6/site-packages/skimage/color/colorconv.py:993: UserWarning: Color data out of range: Z < 0 in 1 pixels
  warn('Color data out of range: Z < 0 in %s pixels' % invalid[0].size)
(epoch: 3, iters: 46, time: 1.969, data: 0.001) G_GAN: 1.649 G_L1: 6.898 D_real: 0.287 D_fake: 0.464 
(epoch: 3, iters: 146, time: 0.270, data: 0.001) G_GAN: 1.509 G_L1: 6.306 D_real: 0.352 D_fake: 0.305 
End of epoch 3 / 200 	 Time Taken: 40 sec
learning rate = 0.0002000
(epoch: 4, iters: 69, time: 0.265, data: 0.001) G_GAN: 1.253 G_L1: 6.059 D_real: 0.510 D_fake: 0.953 
(epoch: 4, iters: 169, time: 0.196, data: 0.003) G_GAN: 0.947 G_L1: 6.058 D_real: 0.804 D_fake: 0.585 
End of epoch 4 / 200 	 Time Taken: 39 sec
learning rate = 0.0002000
(epoch: 5, iters: 92, time: 2.087, data: 0.001) G_GAN: 2.042 G_L1: 7.112 D_real: 0.152 D_fake: 0.200 
saving the model at the end of epoch 5, iters 885
End of epoch 5 / 200 	 Time Taken: 43 sec
learning rate = 0.0002000
(epoch: 6, iters: 15, time: 0.277, data: 0.010) G_GAN: 0.903 G_L1: 6.613 D_real: 0.639 D_fake: 0.441 
(epoch: 6, iters: 115, time: 0.270, data: 0.001) G_GAN: 2.314 G_L1: 6.444 D_real: 0.176 D_fake: 0.303 
End of epoch 6 / 200 	 Time Taken: 40 sec
learning rate = 0.0002000
(epoch: 7, iters: 38, time: 0.191, data: 0.004) G_GAN: 1.304 G_L1: 12.131 D_real: 0.057 D_fake: 0.472 
/opt/conda/lib/python3.6/site-packages/skimage/color/colorconv.py:993: UserWarning: Color data out of range: Z < 0 in 4 pixels
  warn('Color data out of range: Z < 0 in %s pixels' % invalid[0].size)
(epoch: 7, iters: 138, time: 1.834, data: 0.008) G_GAN: 0.701 G_L1: 5.704 D_real: 1.004 D_fake: 0.786 
End of epoch 7 / 200 	 Time Taken: 40 sec
learning rate = 0.0002000
(epoch: 8, iters: 61, time: 0.270, data: 0.004) G_GAN: 1.011 G_L1: 9.289 D_real: 0.300 D_fake: 0.802 
(epoch: 8, iters: 161, time: 0.269, data: 0.087) G_GAN: 1.137 G_L1: 5.043 D_real: 0.582 D_fake: 0.552 
End of epoch 8 / 200 	 Time Taken: 39 sec
learning rate = 0.0002000
(epoch: 9, iters: 84, time: 0.263, data: 0.001) G_GAN: 1.027 G_L1: 6.764 D_real: 0.139 D_fake: 0.726 
End of epoch 9 / 200 	 Time Taken: 39 sec
learning rate = 0.0002000
(epoch: 10, iters: 7, time: 2.186, data: 0.001) G_GAN: 1.731 G_L1: 5.630 D_real: 0.593 D_fake: 0.372 
(epoch: 10, iters: 107, time: 0.268, data: 0.003) G_GAN: 0.912 G_L1: 7.237 D_real: 0.748 D_fake: 0.669 
saving the model at the end of epoch 10, iters 1770
End of epoch 10 / 200 	 Time Taken: 42 sec
learning rate = 0.0002000
(epoch: 11, iters: 30, time: 0.265, data: 0.114) G_GAN: 1.329 G_L1: 8.160 D_real: 0.319 D_fake: 0.395 
(epoch: 11, iters: 130, time: 0.274, data: 0.001) G_GAN: 1.281 G_L1: 8.789 D_real: 1.414 D_fake: 0.346 
End of epoch 11 / 200 	 Time Taken: 39 sec
learning rate = 0.0002000
/opt/conda/lib/python3.6/site-packages/skimage/color/colorconv.py:993: UserWarning: Color data out of range: Z < 0 in 39 pixels
  warn('Color data out of range: Z < 0 in %s pixels' % invalid[0].size)
(epoch: 12, iters: 53, time: 2.049, data: 0.001) G_GAN: 1.694 G_L1: 7.102 D_real: 2.170 D_fake: 0.366 
(epoch: 12, iters: 153, time: 0.271, data: 0.001) G_GAN: 1.201 G_L1: 5.128 D_real: 0.416 D_fake: 0.591 
End of epoch 12 / 200 	 Time Taken: 40 sec
learning rate = 0.0002000
(epoch: 13, iters: 76, time: 0.273, data: 0.001) G_GAN: 1.595 G_L1: 13.226 D_real: 0.127 D_fake: 0.252 
(epoch: 13, iters: 176, time: 0.174, data: 0.006) G_GAN: 1.429 G_L1: 6.739 D_real: 0.693 D_fake: 0.551 
End of epoch 13 / 200 	 Time Taken: 39 sec
learning rate = 0.0002000
(epoch: 14, iters: 99, time: 2.208, data: 0.005) G_GAN: 1.435 G_L1: 8.407 D_real: 0.335 D_fake: 0.461 
End of epoch 14 / 200 	 Time Taken: 41 sec
learning rate = 0.0002000
(epoch: 15, iters: 22, time: 0.267, data: 0.004) G_GAN: 1.075 G_L1: 8.462 D_real: 0.407 D_fake: 1.370 
(epoch: 15, iters: 122, time: 0.272, data: 0.001) G_GAN: 1.029 G_L1: 8.709 D_real: 0.192 D_fake: 0.925 
saving the model at the end of epoch 15, iters 2655
End of epoch 15 / 200 	 Time Taken: 41 sec
learning rate = 0.0002000
(epoch: 16, iters: 45, time: 0.268, data: 0.001) G_GAN: 1.204 G_L1: 7.355 D_real: 0.720 D_fake: 0.603 
(epoch: 16, iters: 145, time: 1.730, data: 0.079) G_GAN: 1.613 G_L1: 5.572 D_real: 0.329 D_fake: 0.310 
End of epoch 16 / 200 	 Time Taken: 40 sec
learning rate = 0.0002000
(epoch: 17, iters: 68, time: 0.193, data: 0.001) G_GAN: 1.202 G_L1: 6.875 D_real: 0.391 D_fake: 0.506 
(epoch: 17, iters: 168, time: 0.270, data: 0.001) G_GAN: 0.924 G_L1: 4.429 D_real: 0.572 D_fake: 0.469 
End of epoch 17 / 200 	 Time Taken: 40 sec
learning rate = 0.0002000
(epoch: 18, iters: 91, time: 0.273, data: 0.102) G_GAN: 1.390 G_L1: 7.051 D_real: 1.207 D_fake: 0.188 
End of epoch 18 / 200 	 Time Taken: 39 sec
learning rate = 0.0002000
/opt/conda/lib/python3.6/site-packages/skimage/color/colorconv.py:993: UserWarning: Color data out of range: Z < 0 in 312 pixels
  warn('Color data out of range: Z < 0 in %s pixels' % invalid[0].size)
(epoch: 19, iters: 14, time: 2.191, data: 0.001) G_GAN: 0.651 G_L1: 5.249 D_real: 1.723 D_fake: 0.489 
(epoch: 19, iters: 114, time: 0.197, data: 0.004) G_GAN: 1.681 G_L1: 5.852 D_real: 0.072 D_fake: 0.485 
End of epoch 19 / 200 	 Time Taken: 41 sec
learning rate = 0.0002000
(epoch: 20, iters: 37, time: 0.268, data: 0.001) G_GAN: 1.010 G_L1: 4.783 D_real: 0.605 D_fake: 0.700 
(epoch: 20, iters: 137, time: 0.196, data: 0.001) G_GAN: 0.606 G_L1: 7.134 D_real: 0.128 D_fake: 1.521 
saving the model at the end of epoch 20, iters 3540
End of epoch 20 / 200 	 Time Taken: 42 sec
learning rate = 0.0002000
/opt/conda/lib/python3.6/site-packages/skimage/color/colorconv.py:993: UserWarning: Color data out of range: Z < 0 in 25 pixels
  warn('Color data out of range: Z < 0 in %s pixels' % invalid[0].size)
(epoch: 21, iters: 60, time: 2.050, data: 0.001) G_GAN: 1.337 G_L1: 6.694 D_real: 0.368 D_fake: 0.311 
(epoch: 21, iters: 160, time: 0.195, data: 0.001) G_GAN: 1.376 G_L1: 6.284 D_real: 1.164 D_fake: 0.375 
End of epoch 21 / 200 	 Time Taken: 40 sec
learning rate = 0.0002000
(epoch: 22, iters: 83, time: 0.272, data: 0.001) G_GAN: 1.813 G_L1: 6.770 D_real: 0.386 D_fake: 0.195 
End of epoch 22 / 200 	 Time Taken: 40 sec
learning rate = 0.0002000
(epoch: 23, iters: 6, time: 0.197, data: 0.001) G_GAN: 1.216 G_L1: 3.667 D_real: 1.312 D_fake: 0.339 
/opt/conda/lib/python3.6/site-packages/skimage/color/colorconv.py:993: UserWarning: Color data out of range: Z < 0 in 9 pixels
  warn('Color data out of range: Z < 0 in %s pixels' % invalid[0].size)
(epoch: 23, iters: 106, time: 2.109, data: 0.001) G_GAN: 1.765 G_L1: 8.450 D_real: 0.239 D_fake: 0.314 
End of epoch 23 / 200 	 Time Taken: 40 sec
learning rate = 0.0002000
(epoch: 24, iters: 29, time: 0.269, data: 0.002) G_GAN: 2.283 G_L1: 6.092 D_real: 0.181 D_fake: 0.147 
(epoch: 24, iters: 129, time: 0.270, data: 0.285) G_GAN: 1.285 G_L1: 5.715 D_real: 0.204 D_fake: 0.561 
End of epoch 24 / 200 	 Time Taken: 40 sec
learning rate = 0.0002000
(epoch: 25, iters: 52, time: 0.270, data: 0.026) G_GAN: 1.003 G_L1: 7.764 D_real: 0.851 D_fake: 0.444 
^C
Traceback (most recent call last):
  File "train.py", line 51, in <module>
    model.optimize_parameters()   # calculate loss functions, get gradients, update network weights
  File "/datasets/home/home-03/75/075/lgong/ml-art-project4/models/pix2pix_model.py", line 126, in optimize_parameters
    self.backward_G()                   # calculate graidents for G
  File "/datasets/home/home-03/75/075/lgong/ml-art-project4/models/pix2pix_model.py", line 111, in backward_G
    self.loss_G_L1 = self.criterionL1(self.fake_B, self.real_B) * self.opt.lambda_L1
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/loss.py", line 93, in forward
    return F.l1_loss(input, target, reduction=self.reduction)
  File "/opt/conda/lib/python3.6/site-packages/torch/nn/functional.py", line 2135, in l1_loss
    ret = torch._C._nn.l1_loss(expanded_input, expanded_target, _Reduction.get_enum(reduction))
KeyboardInterrupt
In [62]:
# Generate colored pages from B&W testset.
! python test.py --dataroot ./datasets/onepiece/A/ --name color_pix2pix --model colorization --netG unet_512 --load_size 512 --crop_size 512 --num_test 8
----------------- Options ---------------
             aspect_ratio: 1.0                           
               batch_size: 1                             
          checkpoints_dir: ./checkpoints                 
                crop_size: 512                           	[default: 256]
                 dataroot: ./datasets/onepiece/A/        	[default: None]
             dataset_mode: colorization                  
                direction: AtoB                          
          display_winsize: 256                           
                    epoch: latest                        
                     eval: False                         
                  gpu_ids: 0                             
                init_gain: 0.02                          
                init_type: normal                        
                 input_nc: 1                             
                  isTrain: False                         	[default: None]
                load_iter: 0                             	[default: 0]
                load_size: 512                           	[default: 256]
         max_dataset_size: inf                           
                    model: colorization                  	[default: test]
               n_layers_D: 3                             
                     name: color_pix2pix                 	[default: experiment_name]
                      ndf: 64                            
                     netD: basic                         
                     netG: unet_512                      	[default: unet_256]
                      ngf: 64                            
               no_dropout: False                         
                  no_flip: False                         
                     norm: batch                         
                    ntest: inf                           
                 num_test: 8                             	[default: 50]
              num_threads: 4                             
                output_nc: 2                             
                    phase: test                          
               preprocess: resize_and_crop               
              results_dir: ./results/                    
           serial_batches: False                         
                   suffix:                               
                  verbose: False                         
----------------- End -------------------
dataset [ColorizationDataset] was created
initialize network with normal
model [ColorizationModel] was created
loading the model from ./checkpoints/color_pix2pix/latest_net_G.pth
---------- Networks initialized -------------
[Network G] Total number of parameters : 66.995 M
-----------------------------------------------
/opt/conda/lib/python3.6/site-packages/skimage/color/colorconv.py:993: UserWarning: Color data out of range: Z < 0 in 6 pixels
  warn('Color data out of range: Z < 0 in %s pixels' % invalid[0].size)
processing (0000)-th image... ['./datasets/onepiece/A/test/0001-011.png.jpeg']
/opt/conda/lib/python3.6/site-packages/skimage/color/colorconv.py:993: UserWarning: Color data out of range: Z < 0 in 22 pixels
  warn('Color data out of range: Z < 0 in %s pixels' % invalid[0].size)
/opt/conda/lib/python3.6/site-packages/skimage/color/colorconv.py:993: UserWarning: Color data out of range: Z < 0 in 19 pixels
  warn('Color data out of range: Z < 0 in %s pixels' % invalid[0].size)
/opt/conda/lib/python3.6/site-packages/skimage/color/colorconv.py:993: UserWarning: Color data out of range: Z < 0 in 34 pixels
  warn('Color data out of range: Z < 0 in %s pixels' % invalid[0].size)
/opt/conda/lib/python3.6/site-packages/skimage/color/colorconv.py:993: UserWarning: Color data out of range: Z < 0 in 51 pixels
  warn('Color data out of range: Z < 0 in %s pixels' % invalid[0].size)
/opt/conda/lib/python3.6/site-packages/skimage/color/colorconv.py:993: UserWarning: Color data out of range: Z < 0 in 56 pixels
  warn('Color data out of range: Z < 0 in %s pixels' % invalid[0].size)
processing (0005)-th image... ['./datasets/onepiece/A/test/0005-011.png.jpeg']
/opt/conda/lib/python3.6/site-packages/skimage/color/colorconv.py:993: UserWarning: Color data out of range: Z < 0 in 16 pixels
  warn('Color data out of range: Z < 0 in %s pixels' % invalid[0].size)
/opt/conda/lib/python3.6/site-packages/skimage/color/colorconv.py:993: UserWarning: Color data out of range: Z < 0 in 29 pixels
  warn('Color data out of range: Z < 0 in %s pixels' % invalid[0].size)
In [63]:
# resize outputs to appropriate resolution

result_dir = "results/color_pix2pix/test_latest/images/"

img_list = os.listdir(result_dir)
num_imgs = len(img_list)
for n in range(num_imgs):
    name_s = img_list[n]
    path_s = os.path.join(result_dir, name_s)
    im_s = cv2.imread(path_s, 1)
    im_l = cv2.resize(im_s, (520,800), interpolation = cv2.INTER_CUBIC)
    cv2.imwrite(path_s, im_l)
    
# The result is in html form stored in results/color_pix2pix/test_latest/