Git Product home page Git Product logo

Comments (5)

tdeboissiere avatar tdeboissiere commented on August 20, 2024

Which keras version are you using ?
It could have something to do with the Batch Norm mode (in early versions, you have a mode to compute BN statistics for inference in the same way as for training, i.e. use a per batch mean and standard dev. If you are in this mode, then when you make predictions, the estimated BN statistics given only one image may not be very good)

Do you have image samples ?
Do you get the same quality if you save with cv2.imwrite ?

from deeplearningimplementations.

s4chin avatar s4chin commented on August 20, 2024

Keras version is 1.2.2
For using cv2.imwrite i have to multiply out by 255, but the saved images look more or less the same.
Here are the images(at 350th epoch) generated by the plot_generated_batch-
current_batch_350_100validation
Here are the same generated images at same epoch by the above code -
0079
0059
0102
0088
Also, I now run the above code every 50 epochs during training itself using the generator_model so as to remove any errors that may be caused due to saving and loading models.

from deeplearningimplementations.

tdeboissiere avatar tdeboissiere commented on August 20, 2024

If I'm not mistaken, during training, predictions are made in batch before being saved:

X_pred = generator.predict(X_batch) # X_batch is maybe (16,3,256,256) for i in range(X_pred.shape[0]): cv2.imwrite(X_pred[i])

However you call predict on a single image.

2 possibilities:

  • You are in the BN mode where moving mean and stddev are computed at training to be re-used at test time. In this case I would expect the same results whether you predict on a single image of a whole batch of image.
  • You are in the BN mode where moving mean and stddev are computed at test time for each new batch you pass. You will get different results depending on how many images are in your test batch. That may explain your artifacts.

Did you try running your image saving code on multiple images at the same time (i.e. data has more than 1 sample on axis=0) ? Do check the mode argument in the BatchNorm layer.

I met a few float/int issues before but these led to images far more deteriorated than the ones you show.

from deeplearningimplementations.

s4chin avatar s4chin commented on August 20, 2024

Alright, it was the case 2. Predicting in a batch led to no artifacts, and patches. I predicted on multiple images together and it worked. 👍
Also, having a batch of 4 gave slightly better results in terms of colors than a batch of 16. I guess that has something to do with having a batch_size of 4 during training too.
Thank you!

from deeplearningimplementations.

tvpian avatar tvpian commented on August 20, 2024

Hi Sachin,
I'm a newbie in the field of deep learning. Out of pure interest I have started to work on pix2pix. I need a small help. I completed the training of my model and now I want to test it on single new images. Can you please brief me how to do it. To be particular I'm working on the Layout-Building example.I used your testing code above to test my model too.Unfortunately the output that I obtained seem to vary a lot from the actual expected output.
1
new

Thank you.
Tharun

from deeplearningimplementations.

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.