Comments (5)
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.
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.
@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.
@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.
@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)
- Issue with running predict.py file HOT 4
- IndexError: too many indices error when running bootstrap.py HOT 8
- Same problem with fine tuning. HOT 1
- train error:ValueError: Input arrays should have the same number of samples as target arrays HOT 11
- predict.py fails on vgg16 HOT 1
- Dataset directory's structure HOT 4
- dict().values returns dict_values in python 3.6 HOT 1
- server.py ValueError
- ValueError: Dimension 1 in both shapes must be equal, but are 0 and 100 for 'Assign_320' (op: 'Assign') with input shapes: [2048,0], [2048,100].
- Is some change needed in resnet50.py? Error while creating model HOT 1
- Error in weights file I guess...I am at a loss HOT 13
- Request for enhancement
- Pretrained model HOT 2
- System calls classification
- What does the '[103.939, 116.779, 123.68]' means?
- How can I avoid "early stopping"?
- cannot download vgg16_tf_dim_ordering_notop.h5 file. HOT 9
- Value error: input samples have different number of arrays with target samples. HOT 8
- me again. Keyerror. "Unable to open object (Object 'fc1' doesn't exist)" HOT 4
- finetuning multiclass model HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keras-transfer-learning-for-oxford102.