diff --git a/README.md b/README.md index 5c20ea9..28122e6 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,8 @@ Embarrassingly, because the neural network was trained to decensor horizontally - TensorFlow 1.5 - Pillow - tqdm -- scipy -- pyamg +- scipy (only needed if poisson blending is enabled in decensor.py) +- pyamg (only needed if poisson blending is enabled in decensor.py) - matplotlib (only for running test.py) Tested on Ubuntu 16.04. Cannot run on Windows since Tensorflow on Windows is for Python 3. diff --git a/decensor.py b/decensor.py index 630f93d..2ec8b99 100644 --- a/decensor.py +++ b/decensor.py @@ -40,13 +40,13 @@ def decensor(): for file in sorted(files): file_path = os.path.join(subdir, file) if os.path.isfile(file_path) and os.path.splitext(file_path)[1] == ".png": - print file_path + print(file_path) image = Image.open(file_path).convert('RGB') image = np.array(image) image = np.array(image / 127.5 - 1) x_decensor.append(image) x_decensor = np.array(x_decensor) - print x_decensor.shape + print(x_decensor.shape) step_num = int(len(x_decensor) / BATCH_SIZE) cnt = 0 @@ -60,8 +60,9 @@ def decensor(): img = np.array((img + 1) * 127.5, dtype=np.uint8) original = x_batch[i] original = np.array((original + 1) * 127.5, dtype=np.uint8) - output = blend(original, img, mask_batch[0,:,:,0]) - output = Image.fromarray(output.astype('uint8'), 'RGB') + #uncomment to enable poisson_blending, but poisson_blending doesn't seem to help + #img = blend(original, img, mask_batch[0,:,:,0]) + output = Image.fromarray(img.astype('uint8'), 'RGB') dst = './decensor_output_images/{}.png'.format("{0:06d}".format(cnt)) output.save(dst)