Code Monkey home page Code Monkey logo

Comments (3)

phillipi avatar phillipi commented on May 22, 2024 1

From http://pytorch.org/docs/nn.html:

At evaluation time (.eval()), the default behaviour of the InstanceNorm module stays the same i.e. running mean/variance is NOT used for normalization. One can force using stored mean and variance with .train(False) method.

However, the results might not look so good since instance norm isn't really meant to be used this way -- this will induce a big gap between how you trained instance norm and how it is being used at test time.

If it doesn't look good, you could try retraining in a way that removes this gap. One way would be "virtual instance norm", where you normalize one image based on the running statistics from a held out set of other images (same as virtual batchnorm from this paper).

Good luck and I'll be interested to know if you have success!

from cyclegan.

DmitryUlyanov avatar DmitryUlyanov commented on May 22, 2024 1

Hi, torch implementation of Instance Norm is easily hackable and can use stored mean/var instead of independent normalization at test time. I think you just need to set self.bn to eval mode in https://github.com/junyanz/CycleGAN/blob/master/util/InstanceNormalization.lua#L102 or somewhere in updateOutput function. Stored statistics worked quite well for stylization.

Ideally, you want to get statistics from an entire image, you can create a dataset of tiles and compute global statistcs. I saw a script by @szagoruyko which does it, but could not find it now.

from cyclegan.

junyanz avatar junyanz commented on May 22, 2024

@DmitryUlyanov Thanks for the notes.

@Quasimondo I guess the tiling operation will still cause the boundary artifacts even without instanceNorm.

Let's say your images are 512x512. I would recommend that you train your model on 256x256 cropped images. During the test time, you are still able to test it on large images (512x512), as testing requires less GPU memory, compared to training. In this case, you might want to set loadSize=512 and fineSize=256 for both training and test. Even you train a model on 256x256 images, you can still apply it fully convolutionally to a picture with arbitrary size.

See issue #19 for more discussion.

from cyclegan.

Related Issues (20)

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.