OlafenwaMoses / ImageAI

A python library built to empower developers to build applications and systems with self-contained Computer Vision capabilities
https://www.genxr.co/#products
MIT License
8.62k stars 2.19k forks source link

Got exception in the custom model training example #97

Closed roybs2 closed 5 years ago

roybs2 commented 6 years ago

Hey, I'm using python 3.5.4 Tensorflow version 1.11.0

I tried to do custom model training, I used your example just instead of pets I did something else but with the same hierarchy of folders. This is the code: from imageai.Prediction.Custom import ModelTraining model_trainer = ModelTraining() model_trainer.setModelTypeAsResNet() model_trainer.setDataDirectory("tables") model_trainer.trainModel(num_objects=4, num_experiments=100, enhance_data=True, batch_size=32, show_network_summary=True)

Any suggestions?

and I got this error:

Traceback (most recent call last): File "E:/Programing/Python/bills-info/AI/traingAi.py", line 5, in model_trainer.trainModel(num_objects=4, num_experiments=100, enhance_data=True, batch_size=32, show_network_summary=True) File "E:\Programing\Python\bills-info\env\lib\site-packages\imageai\Prediction\Custom__init__.py", line 249, in trainModel validation_steps=int(num_test / batch_size), callbacks=[checkpoint, lr_scheduler]) File "E:\Programing\Python\bills-info\env\lib\site-packages\tensorflow\python\keras\engine\training.py", line 2065, in fit_generator initial_epoch=initial_epoch) File "E:\Programing\Python\bills-info\env\lib\site-packages\tensorflow\python\keras\engine\training_generator.py", line 211, in fit_generator callbacks.on_epoch_end(epoch, epoch_logs) File "E:\Programing\Python\bills-info\env\lib\site-packages\tensorflow\python\keras\callbacks.py", line 214, in on_epoch_end callback.on_epoch_end(epoch, logs) File "E:\Programing\Python\bills-info\env\lib\site-packages\tensorflow\python\keras\callbacks.py", line 568, in on_epoch_end filepath = self.filepath.format(epoch=epoch + 1, **logs) KeyError: 'val_acc'

OlafenwaMoses commented 6 years ago

How many pictures do you have for the test and train images for all the 4 classes?

roybs2 commented 6 years ago

not much, something between 5-15 How many I need?

OlafenwaMoses commented 6 years ago

You should have at least 500 images in each class train sub folder and 100 images in each class test sub folder . Follow the link below to read the article on this.

https://towardsdatascience.com/train-image-recognition-ai-with-5-lines-of-code-8ed0bdd8d9ba

bedna-KU commented 5 years ago

@OlafenwaMoses you are a complete amateur wrap it!

This is really shit project.