Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hepesu committed Sep 18, 2018
1 parent b6f0b3d commit 4fefc11
Showing 10 changed files with 50 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
# LineCloser
Unofficial Keras implementation of Joint Gap Detection and Inpainting of Line Drawings.

## Overview
Joint gap for line-drawings. Model1 uses network from the paper. For stable training, BN was added for all Conv2D. Model2 uses common network for inpaint. Training code will be uploaded soon.

## Dependencies
* Keras2 (Tensorflow backend)
* OpenCV3

## Usage
1. Set up directories.

2. Download the model from release and put it in the same folder with code.

3. Run `predict.py` for prediction.

## Models
Models are licensed under a CC-BY-NC-SA 4.0 international license.

From **Project HAT** by Hepesu With :heart:
Binary file added input/0.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 input/1.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 input/2.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 input/3.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 output/0.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 output/1.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 output/2.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 output/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions predict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os

# Try running on CPU
os.environ['CUDA_VISIBLE_DEVICES'] = '-1'

import numpy as np
import cv2
from keras.models import load_model

R = 2 ** 4
MODEL_NAME = 'model1.h5'

model = load_model(MODEL_NAME)
model.summary()

for root, dirs, files in os.walk('input', topdown=False):
for name in files:
print(os.path.join(root, name))

im = cv2.imread(os.path.join(root, name), cv2.IMREAD_GRAYSCALE)

im_predict = cv2.resize(im, (im.shape[1] // R * R, im.shape[0] // R * R))
im_predict = np.reshape(im_predict, (1, im_predict.shape[0], im_predict.shape[1], 1))
im_predict = im_predict.astype(np.float32) / 255.

result = model.predict(im_predict)

result = np.squeeze(result) * 255.
im_res = cv2.resize(result, (im.shape[1], im.shape[0]))

cv2.imwrite(os.path.join('output', name), im_res)

0 comments on commit 4fefc11

Please sign in to comment.