• Stars
    star
    1,352
  • Rank 34,754 (Top 0.7 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 7 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Demo of in-browser Fast Neural Style Transfer with deeplearn.js library

Fast Neural Style Transfer in browser with deeplearn.js

DEPRECATED: This repository has been deprecated and is no longer actively maintained (build instructions no longer work either). There is a much, much better version (where you can use ANY style) at https://github.com/reiinakano/arbitrary-image-stylization-tfjs. If you're really interested in this version of fast style transfer, this code has been integrated into the ml5.js library and the TensorFlow.js version is actively maintained over there.

This repository contains an implementation of the Fast Neural Style Transfer algorithm running fully inside a browser using the Deeplearn.JS library.

Demo website: https://reiinakano.github.io/fast-style-transfer-deeplearnjs

demo_screen

FAQ

What is this about?

This is an implementation of the Fast Neural Style Transfer algorithm running purely on the browser using the Deeplearn.JS library. Basically, a neural network attempts to "draw" one picture, the Content, in the style of another, the Style.

Is my data safe? Can you see my webcam pics?

Your data and pictures here never leave your computer! In fact, this is one of the main advantages of running neural networks in your browser. Instead of sending us your data, we send you both the model and the code to run the model. These are then run by your browser.

How big are the models I'm downloading?

For each available style, your browser will download a model around ~6.6MB in size. Be careful if you have limited bandwidth (mobile data users).

The web page is ugly.

I know. Sorry, I'm not really a UI designer. I have about a 10 minute tolerance for tweaking HTML and CSS until I give up. The good news is, it's all open source on Github! If you want to help improve the page's design, please send a pull request! :)

Development

To run this locally, clone the project and prepare the development environment:

$ git clone https://github.com/reiinakano/fast-style-transfer-deeplearnjs.git
$ cd fast-style-transfer-deeplearnjs
$ npm install && bower install # Install node modules and bower components

To interactively develop the application

$ ./scripts/watch-demo src/styletransfer-demo.ts
>> Waiting for initial compile...
>> 1023189 bytes written to src/bundle.js (0.71 seconds) at 2:20:06 AM
>> Starting up http-server, serving ./
>> Available on:
>>   http://127.0.0.1:8080
>> Hit CTRL-C to stop the server

The application will be available at http://localhost:8080/src/styletransfer-demo.html and will watch for changes of typescript code.

Adding your own styles

The way Fast Neural Style Transfer works is, one has to train a new neural network for each "Style" image and upload it to the server. Training takes 4-6 hours on a relatively powerful GPU (Maxwell Titan X).

To train your own style model from scratch, please follow the instructions from this Github repository to get your own .ckpt file. You will need Python, Tensorflow, and a decent GPU.

Once you have the model.ckpt file for your style, run the following:

$ python scripts/dump_checkpoint_vars.py --output_dir=src/ckpts/my-new-style --checkpoint_file=/path/to/model.ckpt
$ python scripts/remove_optimizer_variables.py --output_dir=src/ckpts/my-new-style

If all goes well, src/ckpts/my-new-style should contain ~6.7MB of 49 items including a manifest.json file.

Adding the style to the application is then as simple as modifying the STYLE_MAPPINGS variable in src/styletransfer-demo.ts.

If you're able to successfully achieve cool new styles, I'd be glad to add them to this demo!

Credits

Credits belong to the following:

More Repositories

1

scikit-plot

An intuitive library to add plotting functionality to scikit-learn objects.
Python
2,401
star
2

xcessiv

A web-based application for quick, scalable, and automated hyperparameter tuning and stacked ensembling in Python.
Python
1,266
star
3

arbitrary-image-stylization-tfjs

Arbitrary style transfer using TensorFlow.js
JavaScript
1,184
star
4

gan-playground

GAN Playground - Experiment with Generative Adversarial Nets in your browser. An introduction to GANs.
TypeScript
347
star
5

neural-painters

Jupyter Notebook
262
star
6

neural-painters-pytorch

PyTorch library for "Neural Painters: A learned differentiable constraint for generating brushstroke paintings"
Jupyter Notebook
139
star
7

invariant-risk-minimization

Implementation of Invariant Risk Minimization https://arxiv.org/abs/1907.02893
Jupyter Notebook
84
star
8

tfjs-lstm-text-generation

Generate your own Nietschze quote using TensorFlow.js
JavaScript
15
star
9

tfjs-rock-paper-scissors

Play Rock Paper Scissors with your webcam using TensorFlow.js
JavaScript
14
star
10

adversarially-robust-neural-style-transfer

Jupyter Notebook
8
star
11

gnuradio-go

Python
6
star
12

tfjs-autoencoder

A denoising autoencoder written in TensorFlow.js
HTML
6
star
13

pix2pix-runway

Python
5
star
14

my-resume

Here be my resume.
5
star
15

wifisniffer

Automatically decrypts and displays WiFi packets captured from the air. This is unfinished and no longer maintained.
Python
3
star
16

post--robust-neural-style

JavaScript
1
star
17

msk-cancer

Repository for storing some of my notebooks for Kaggle's competition https://www.kaggle.com/c/msk-redefining-cancer-treatment/
Jupyter Notebook
1
star
18

KDD-2010-mini-project

Just a messy filedump of all my ipython notebooks for "competing" in the KDD 2010 Cup Challenge
Jupyter Notebook
1
star
19

personal_exercises

Short scripts I write for practicing software engineering interviews
Python
1
star