Coder Social home page Coder Social logo

rkshuai / contextualloss Goto Github PK

View Code? Open in Web Editor NEW

This project forked from roimehrez/contextualloss

0.0 2.0 0.0 9.98 MB

The Contextual Loss

Home Page: http://cgm.technion.ac.il/Computer-Graphics-Multimedia/Software/Contextual/

Python 100.00%

contextualloss's Introduction

The Contextual Loss [project page]

This is a Tensorflow implementation of the Contextual loss function as reported in the following papers: (PyTorch implementation is also available - see bellow)

The Contextual Loss for Image Transformation with Non-Aligned Data, arXiv

Learning to Maintain Natural Image Statistics, arXiv

Roey Mechrez*, Itamar Talmi*, Firas Shama, Lihi Zelnik-Manor. The Technion

Copyright 2018 Itamar Talmi and Roey Mechrez Licensed for noncommercial research use only.

Setup

Background

This code is mainly the contextual loss function. The two papers have many applications, here we provide only one applications: animation from single image.

An example pre-trained model can be download from this link

The data for this example can be download from this link

Requirement

Required python libraries: Tensorflow (>=1.0, tested on 1.4) + Scipy + Numpy + easydict

Tested in Windows + Intel i7 CPU + Nvidia Titan Xp (and 1080ti) with Cuda (>=8.0) and CuDNN (>=5.0). CPU mode should also work with minor changes.

Quick Start (Testing)

  1. Clone this repository.
  2. Download the pretrained model from this link
  3. Extract the zip file under result folder. The models should be in based_dir/result/single_im_D32_42_1.0_DC42_1.0/
  4. Update the config.base_dir and config.vgg_model_path in config.py and run: single_image_animation.py

Training

  1. Change config.TRAIN.to_train to True
  2. Arrange the paths to the data, should have train and test folders
  3. run single_image_animation.py for 10 epochs.

Pytorch implemntation

We have also released a PyTorch implementation of the loss function. See CX/CX_distance.py. Note that we havn't test this implemntation to reproduce the results in the paper.

License

This software is provided under the provisions of the Lesser GNU Public License (LGPL). see: http://www.gnu.org/copyleft/lesser.html.

This software can be used only for research purposes, you should cite the aforementioned papers in any resulting publication.

The Software is provided "as is", without warranty of any kind.

Citation

If you use our code for research, please cite our paper:

@article{mechrez2018contextual,
  title={The Contextual Loss for Image Transformation with Non-Aligned Data},
  author={Mechrez, Roey and Talmi, Itamar and Zelnik-Manor, Lihi},
  journal={arXiv preprint arXiv:1803.02077},
  year={2018}
}
@article{mechrez2018Learning,
  title={Learning to Maintain Natural Image Statistics, [arXiv](https://arxiv.org/abs/1803.04626)},
  author={Mechrez, Roey and Talmi, Itamar and Shama, Firas and Zelnik-Manor, Lihi},
  journal={arXiv preprint arXiv:1803.04626},
  year={2018}
}

Code References

[1] Template Matching with Deformable Diversity Similarity, https://github.com/roimehrez/DDIS

[2] Photographic Image Synthesis with Cascaded Refinement Networks https://cqf.io/ImageSynthesis/

contextualloss's People

Contributors

roimehrez avatar

Watchers

 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.