Skip to content
Photo-sharing social network built around style transfer. User uploaded photos can be run through a Tensorflow model to generate a new image, blending the content of the photo with the style of a source painting
CSS Python JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
fast_style_transfer
static
templates
.gitignore
CONTRIBUTING.md
LICENSE.md
README.md
model.py
nginx.conf
requirements.txt
seed.py
server.py
tests.py

README.md

DeepPaint

DeepPaint is a photo sharing webapp built to feature the author's interest in style-transfer via Tensorflow. The initial release was built untilizing fast-style-transfer by Logan Engstrom.

Users upload photos, share them with the DeepPaint community, then process those photos through the style-transfer model to generate new images that blend the content and features of the source photo with the style and texture of select paintings.

Homepage

Getting Started

This project is a full-stack web app that leverages multiple technologies and frameworks. The instructions below are meant to guide you through getting a local instance of Deep-Paint up and running.

Prerequisites

On the back-end, this project was written in Python 2.7 using Flask as the web framework, then Flask-SQLAlchemy as the ORM to connect to a PostgreSQL database. The style-transfer neural network was built using Tensorflow. Prior to getting started, you'll need to make sure you have Python 2.7, and PostgreSQL installed.

I built this project on macOS High Sierra 10.13.4, so instructions are written with that OS. If you are running Linux or Windows, your installation steps will be slightly different.

For those of you using macOS, I highly recommend using brew to get started.

Important note: These are the steps that worked for my specific environment. Your environment may have different requirements.

  1. Install Homebrew
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. Install Python 2.7

Using brew:

$ brew install python@2
$ pip install --upgrade pip setuptools
$ pip install virtualenv
  1. Install and setup PostgreSQL
$ brew install postgres
$ brew services start postgresql

Installing

  1. Clone this repo and cd into it.
$ git clone https://github.com/evinces/deep-paint.git
$ cd deep-paint
  1. Create a virtual environment and activate it.
$ virtualenv env
$ . env/bin/activate
  1. Install the required python packages. I've included a pip freeze dump: requirements.txt.
$ pip install -r requirements.txt
  1. Create the secrets.sh file and run it.
$ echo "export SECRET_KEY='<fill-with-a-secret-key>'" > secrets.sh
$ . secrets.sh
  1. Create the postgres databases.
$ createdb deep-paint
$ createdb deep-paint-testing
  1. Seed the starting data. Download the seed files here. Extract the archive to the project directory, then run seed.py to populate the db.
$ python seed.py
  1. Launch the server.
$ python server.py
  1. Navigate to http://localhost:5000 in a browser window.

Deploying

  1. Spin up the web server of your preference. The host used for deep-paint.com is an AWS EC2 large-t2 instance running Ubuntu 16.4 LTS with the following config:
$ apt-get install -y python-virtualenv
$ apt-get install -y build-essential python-dev
$ apt-get install -y postgresql postgresql-client
$ sudo -u postgres createuser -s ubuntu
$ apt-get install -y postgresql-server-dev-10.3
$ apt-get install -y postgresql-plpython
$ apt-get install -y postgresql-contrib
$ apt-get install -y nginx

1a. The PostgreSQL db will also need to be spun up here. If you've already created the db in your local env, I recommend simply dumping your local db into a .sql file then reading that into the server. On local:

$ pg_dump deep-paint > deep-paint.sql

On server:

$ createdb deep-paint
$ psql deep-paint < deep-paint.sql
  1. Clone this repo on the server and cd into the directory.
$ git clone https://github.com/evinces/deep-paint.git
$ cd deep-paint
  1. Create a virtual environment and pip install requirements.
$ virtualenv env
$ . env/bin/activate
$ pip install -r requirements.txt
  1. Create a secrets.sh file and add a Flask secret key.
$ echo "export SECRET_KEY='<fill-with-a-secret-key>'" > secrets.sh
  1. Spin up the server and verify it is running.
$ tmux
$ . env/bin/activate
$ . secrets.sh
$ python server.py
...
[ctrl+b][d]
$ curl http://localhost:5000
  1. Get an SSL cert from letsenrypt. Note: This step is optional but highly recommended.
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install python-certbot-nginx
$ sudo certbot --nginx
...
[enter your domain]
  1. Modify the nginx.conf file with your domain name, to route https traffic to localhost on the server.
... [after modifying nginx.conf]
$ sudo cp nginx.conf /etc/nginx/sites-enabled/[your-domain].conf
$ sudo /etc/init.d/nginx reload

Built With

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

You can’t perform that action at this time.