GithubHelp home page GithubHelp logo

Comments (5)

Arsey avatar Arsey commented on September 15, 2024 43

Hi @anhlt!
Rescale is a value by which we will multiply the data before any other processing. Our original images consist in RGB coefficients in the 0-255, but such values would be too high for our model to process (given a typical learning rate), so we target values between 0 and 1 instead by scaling with a 1/255. factor (the description taken from https://blog.keras.io/building-powerful-image-classification-models-using-very-little-data.html)

Talking about preprocess_input function, I don't know on which step it can/should be used. I've tried to train model with extracting those mean values and converting to BGR, but then model does not train at all and stack on a very low accuracy (near 0.0387 for each epoch). Then I've tried it on prediction step - results still bad. Also I've noticed that this function is not used inside of Keras.

About mean value here's interesting info - Lasagne/Recipes#20

from keras-transfer-learning-for-oxford102.

Suraj023 avatar Suraj023 commented on September 15, 2024 4

rescale is a value by which we will multiply the data before any other processing. Our original images consist in RGB coefficients in the 0-255, but such values would be too high for our models to process (given a typical learning rate), so we target values between 0 and 1 instead by scaling with a 1./255 factor.

from keras-transfer-learning-for-oxford102.

anhlt avatar anhlt commented on September 15, 2024

@Arsey thank for your answer. Interestingly , I found some preprocess_input implement by @karpathy on his neural-talk repository.

def preprocess_image(img):
    '''
    Preprocess an input image before processing by the caffe module.


    Preprocessing include:
    -----------------------
    1- Converting image to single precision data type
    2- Resizing the input image to cropped_dimensions used in extract_features() matlab script
    3- Reorder color Channel, RGB->BGR
    4- Convert color scale from 0-1 to 0-255 range (actually because image type is a float the 
        actual range could be negative or >255 during the cubic spline interpolation for image resize.
    5- Subtract the VGG dataset mean.
    6- Reorder the image to standard caffe input dimension order ( 3xHxW) 
    '''
    img      = img.astype(np.float32)
    img      = imresize(img,224,224) #cropping the image
    img      = img[:,:,[2,1,0]] #RGB-BGR
    img      = img*255

    mean = np.array([103.939, 116.779, 123.68]) #mean of the vgg 

    for i in range(0,3):
        img[:,:,i] = img[:,:,i] - mean[i] #subtracting the mean
    img = np.transpose(img, [2,0,1])
return img #HxWx3

As you can see, He wrote that

4- Convert color scale from 0-1 to 0-255 range (actually because image type is a float the 
    actual range could be negative or >255 during the cubic spline interpolation for image resize.

I don't think, high value of input can effect learning curve. But I will try both of them and compare the results.

from keras-transfer-learning-for-oxford102.

anhlt avatar anhlt commented on September 15, 2024

@Arsey How accurary you get on validation set? I just got only about 80% .
Happy to have any comment on my repository.
https://github.com/anhlt/keras-102-flower-dataset/

from keras-transfer-learning-for-oxford102.

Arsey avatar Arsey commented on September 15, 2024

@anhlt I have about 81% accuracy after 250th epoch on fine tuning step. I see that you also have GTX 1070, just like me))). BTW which OS do you use?

from keras-transfer-learning-for-oxford102.

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.