georgeseif / transfer-learning-suite Goto Github PK
View Code? Open in Web Editor NEWTransfer Learning Suite in Keras. Perform transfer learning using any built-in Keras image classification model easily!
Transfer Learning Suite in Keras. Perform transfer learning using any built-in Keras image classification model easily!
Hi,GeorgeSeif:
Thanks for your transfer learning code,if I want to setting different learning rate in different layer?Is keras
possible to do this ?
Thanks!
When I make my own dataset , and try to run main.py , there is an error.
I created structure as :
-'dataset'
-train
-class1
(include images)
-class2
-val
-class1
-class2
Details of the error followed:
Found 705 images belonging to 2 classes.
Found 361 images belonging to 2 classes.
Epoch 1/100
Traceback (most recent call last):
File "/home/he/anaconda2/envs/Yolo-keras/lib/python3.5/site-packages/keras/utils/data_utils.py", line 578, in get
inputs = self.queue.get(block=True).get()
File "/home/he/anaconda2/envs/Yolo-keras/lib/python3.5/multiprocessing/pool.py", line 644, in get
raise self._value
File "/home/he/anaconda2/envs/Yolo-keras/lib/python3.5/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/home/he/anaconda2/envs/Yolo-keras/lib/python3.5/site-packages/keras/utils/data_utils.py", line 401, in get_index
return _SHARED_SEQUENCES[uid][i]
File "/home/he/anaconda2/envs/Yolo-keras/lib/python3.5/site-packages/keras/preprocessing/image.py", line 825, in getitem
return self._get_batches_of_transformed_samples(index_array)
File "/home/he/anaconda2/envs/Yolo-keras/lib/python3.5/site-packages/keras/preprocessing/image.py", line 1233, in _get_batches_of_transformed_samples
img = self.image_data_generator.preprocessing_function(img)
File "/home/he/anaconda2/envs/Yolo-keras/lib/python3.5/site-packages/keras/applications/imagenet_utils.py", line 178, in preprocess_input
mode=mode)
File "/home/he/anaconda2/envs/Yolo-keras/lib/python3.5/site-packages/keras/applications/imagenet_utils.py", line 132, in _preprocess_symbolic_input
x = x[..., ::-1]
TypeError: 'Image' object is not subscriptable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/he/pycharm/pycharm-2017.3.4/helpers/pydev/pydevd.py", line 1668, in
main()
File "/home/he/pycharm/pycharm-2017.3.4/helpers/pydev/pydevd.py", line 1662, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/he/pycharm/pycharm-2017.3.4/helpers/pydev/pydevd.py", line 1072, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/he/pycharm/pycharm-2017.3.4/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/he/Code/Transfer-Learning-Suite/main.py", line 206, in
validation_data=validation_generator, validation_steps=num_val_images // BATCH_SIZE, class_weight='auto', shuffle=True, callbacks=callbacks_list)
File "/home/he/anaconda2/envs/Yolo-keras/lib/python3.5/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/home/he/anaconda2/envs/Yolo-keras/lib/python3.5/site-packages/keras/engine/training.py", line 2192, in fit_generator
generator_output = next(output_generator)
File "/home/he/anaconda2/envs/Yolo-keras/lib/python3.5/site-packages/keras/utils/data_utils.py", line 584, in get
six.raise_from(StopIteration(e), e)
File "", line 3, in raise_from
StopIteration: 'Image' object is not subscriptable
Thank you so much.
how to run prediction on test data folder?
OS Platform and Distribution: windows 10
TensorFlow backend: yes
tensorflow 1.13.1
tensorflow-base 1.13.1
tensorflow-estimator 1.13.0
Keras version:
keras 2.2.4
keras-applications 1.0.7
keras-base 2.2.4
keras-preprocessing 1.0.9
Python version:
Python 3.6.5
No cuda
No gpu
On running the code as described, I am getting-
Traceback (most recent call last): File "main.py", line 205, in <module> validation_data=validation_generator, validation_steps=1, class_weight='auto', shuffle=True, callbacks=callbacks_list) File "C:\Users\Win 10\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper return func(*args, **kwargs) File "C:\Users\Win 10\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\engine\training.py", line 1418, in fit_generator initial_epoch=initial_epoch) File "C:\Users\Win 10\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\engine\training_generator.py", line 251, in fit_generator callbacks.on_epoch_end(epoch, epoch_logs) File "C:\Users\Win 10\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\callbacks.py", line 79, in on_epoch_end callback.on_epoch_end(epoch, logs) File "C:\Users\Win 10\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\callbacks.py", line 338, in on_epoch_end self.progbar.update(self.seen, self.log_values) AttributeError: 'ProgbarLogger' object has no attribute 'log_values'
@GeorgeSeif
This is an interesting project. I tried this with dog vs. cat dataset (kaggle) that was running fine. The only problem was the error in plotting.
Epoch 00019: saving model to ./checkpoints/DenseNet201_model_weights.h5
Epoch 20/20
703/703 [==============================] - 149s 212ms/step - loss: 0.0014 - acc: 0.9996 - val_loss: 0.1408 - val_acc: 0.9764
Epoch 00020: saving model to ./checkpoints/DenseNet201_model_weights.h5
Traceback (most recent call last):
File "main.py", line 208, in
plot_training(history)
NameError: name 'plot_training' is not defined
Hi, I am trying to make a predictions, but looks like the function call is not complete.
No significant changes in code was done. I am trying it with python3
Was trained with:
python main.py --mode train --dataset new_train_3 --model InceptionResNetV2
I am trying to predict with:
python main.py --mode predict --image ~/Devel/ai-dev/IMGS/999f2cfbfbde894166bb9a4bbf8df46d.640x360.jpg --model InceptionResNetV2 --dataset new_train_3
How can I get it work?
Nice Work!
Cleanest solution that exists so far.
Any plans to introduce object detection/ bounding box for e.g YOLO?
Hey! Great code by the way, but I want to point out an error. If I try to use InceptionResnetV2, I get "ModuleNotFoundError: No module named 'keras.applications.inceptionresnetv2'"
To fix that change
keras.applications.inceptionresnetv2
to
keras.application.inception_resnet_v2
in your main.py so that it would look like that:
elif args.model == "InceptionResNetV2":
from keras.applications.inception_resnet_v2 import preprocess_input
preprocessing_function = preprocess_input
base_model = InceptionResNetV2(weights='imagenet', include_top=False, input_shape=(HEIGHT, WIDTH, 3))
Should probably be there in the readme?
Hi George,
after preparing my own dataset i run into the following error.
https://i.imgur.com/1WUFlHa.png
Noting the numbers are very close, i tried different models and batch sizes but can not make progress. Do you have an idea what might cause the error?
This is the relevant line from main.py
history = finetune_model.fit_generator(train_generator, epochs=args.num_epochs, workers=8, steps_per_epoch=num_train_images // BATCH_SIZE, validation_data=validation_generator, validation_steps=num_val_images // BATCH_SIZE, class_weight='auto', shuffle=True, callbacks=callbacks_list)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.