Code Monkey home page Code Monkey logo

style_transfer's Introduction

Style Transfer of Images and Videos

Introduction

In this repository, we implement style transfer and analyze various design choices in the algorithm, which is important for learning from the artistic styles of existing artworks and generating new visually pleasing results. We implement two versions of style transfer. The first version requires a long runtime for images with high resolution. We explore many possible solutions and implement the second version that provides a significant speedup. We are able to efficiently stylize high resolution on GPU and scale up to stylizing videos, which requires transforming a large number of frames of the videos.

For Developers

Setup ๐Ÿ› 

  1. Clone the repository
git clone https://github.com/zywangdylan/style_transfer
  1. Upload the folder style_transfer you just cloned to your Google Drive/Colab under the path /content/drive/MyDrive/
  2. Open the notebook Version1_NST.ipynb or Version2_NST.ipynb in Colab
  3. Modify configurations and paths according to the detailed instructions below
  4. Run the code in the notebook ๐Ÿš€

Version 1

The first version of style transfer is implemented in the notebook Version1_NST.ipynb.

Several reminders to run the code in the notebook:

  1. Colab or Local Machine? The notebook is designed to run on Google Colab. You can run the code on your local machine, but you need to install the required packages and change the path to the dataset.
  2. GPU or CPU? The notebook is able to run on GPU. You can change the runtime type to GPU in the notebook. CPU is also supported, but it will take a long time to run the code.
  3. Path? By default, ROOT = '/content/drive/MyDrive/style_transfer' will be the correct path to the folder style_transfer you cloned from the repository. If you run the code on your local machine or put the folder elsewhere in Google Drive, you need to change the path to the folder style_transfer.
  4. Image Sizes? In this version, you are able to transform the images up to 1024x1024 for GPU and 512x512 for CPU. If you want to run the code on images with different sizes, you need to change the gpu_output_image_size and cpu_output_image_size in the notebook.

Version 2

The second version of style transfer is implemented in the notebook Version2_NST.ipynb.

  1. Configs To better support the stylization of images and videos, we implement a config cell to store the parameters of the algorithm. You can change the parameters, such as MODE, path, weights, in the config cell and run the code in the notebook.

  2. Takes a while to run? Yes, it will take a while to run the code when downloading COCO dataset and training the model. If you want to have a quick look at your stylized images, you can change the MODE to IMAGE, setup your Image Style Transfer Configs and run the code in the notebook. The result image will be waiting for you in the folder images/result_images.

  3. Folder structure? Please keep the folder structure the same as the way shown below so that you don't need to configure most of the paths in the notebook.

    .
    โ”œโ”€โ”€ images                                    # Image folder
    โ”‚   โ”œโ”€โ”€ content_images          
    โ”‚   โ”œโ”€โ”€ style_images        
    โ”‚   โ””โ”€โ”€ result_images
    โ”œโ”€โ”€ videos                                    # Image folder 
    โ”‚   โ”œโ”€โ”€ content_videos                
    โ”‚   โ””โ”€โ”€ result_videos
    โ”œโ”€โ”€ training_checkpoints                      # Folder to save model checkpoints
    โ”œโ”€โ”€ trained_transformations                   # Trained weights of styles
    โ”œโ”€โ”€ pretrained_loss_network                   # Folder to save pretrained weights of backbones
    โ”œโ”€โ”€ Version2_NST.ipynb
    โ””โ”€โ”€ Version1_NST.ipynb
    

Report

If you are curious about the logic of the algorithm, report is ready for you in final_project_report.pdf with detail explanation and evaulations.

Google Drive

Using your UPenn SEAS Email Account to view our Google Drive Folder.

Happy Painting! ๐ŸŽจ

style_transfer's People

Contributors

zywangdylan avatar yichengshen avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.