danielgafni / repalette

Image recoloring with deep neural networks (and GANs!)
Apache License 2.0
31 stars 1 forks source link

Usage

  1. Install Docker
  2. Pull the web app container:
    docker pull danielgafni/repalette:app
  3. Run the container:
    docker run -p 8000:8000 danielgafni/repalette:app
  4. Open localhost:8000 in your browser
  5. In the web interface:
    • Upload the image
    • Select the desired color palette
    • Press the "recolor" button

Screenshots

image image

Development

Installation

poetry install
poetry run pre-commit install  # for development

To activate the virtual environment run poetry shell

Configuration

cp ./.env.example ./.env

Fill it with the correct values.

Install Jupyter Lab plugins

# Avoid "JavaScript heap out of memory" errors during extension installation
# (OS X/Linux)
export NODE_OPTIONS=--max-old-space-size=4096
# (Windows)
set NODE_OPTIONS=--max-old-space-size=4096
# Jupyter widgets extension
jupyter labextension install @jupyter-widgets/jupyterlab-manager --no-build

# jupyterlab plotly renderer support
jupyter labextension install jupyterlab-plotly --no-build

# Plotly FigureWidget support
jupyter labextension install plotlywidget --no-build

# Build extensions (must be done to activate extensions since --no-build is used above)
jupyter lab build

# Unset NODE_OPTIONS environment variable
# (OS X/Linux)
unset NODE_OPTIONS
# (Windows)
set NODE_OPTIONS=

Download data

Option 1: scrap data from www.design-seeds.com

python repalette/db/utils/download_raw.py --num-workers 8  # adjust num-workers
python repalette/db/utils/build_rgb.py

Option 2: download prepared data from S3

This data might be a little outdated comparing to the #1 option, but will be downloaded much faster.

python repalette/db/utils/download_rgb_from_s3.py

Update S3 dataset

python repalette/db/utils/upload_rgb_to_s3.py

Download the pre-trained model checkpoint:

python repalette/db/utils/download_pretrain_checkpoint_from_s3.py

Training

The model can be trained on the data downloaded from www.design-seeds.com. After running the training script the logs (losses, images, etc) will be available at localhost:6006.

Pre-training

python repalette/training/pretrain.py

GAN training

python repalette/training/gan.py

Project structure

data