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

Must there be more images?ValueError: Error when checking target: expected activation_50 to have shape (173,) but got array with shape (3,) #203

Closed 54huige closed 5 years ago

54huige commented 5 years ago

Why did it go wrong? Must there be more images?

Found 173 images belonging to 3 classes. Found 240 images belonging to 4 classes. JSON Mapping for the model classes saved to pets/json\model_class.json Number of experiments (Epochs) : 1 Epoch 1/1 Traceback (most recent call last): File "O:\imageAI\main.py", line 5, in model_trainer.trainModel(num_objects=173, num_experiments=1, enhance_data=False, batch_size=32, show_network_summary=True) File "D:\software\python\lib\site-packages\imageai\Prediction\Custom__init__.py", line 249, in trainModel validation_steps=int(num_test / batch_size), callbacks=[checkpoint, lr_scheduler]) File "D:\software\python\lib\site-packages\tensorflow\python\keras_impl\keras\engine\training.py", line 1598, in fit_generator initial_epoch=initial_epoch) File "D:\software\python\lib\site-packages\tensorflow\python\keras_impl\keras\engine\training_generator.py", line 191, in fit_generator x, y, sample_weight=sample_weight, class_weight=class_weight) File "D:\software\python\lib\site-packages\tensorflow\python\keras_impl\keras\engine\training.py", line 1378, in train_on_batch class_weight=class_weight) File "D:\software\python\lib\site-packages\tensorflow\python\keras_impl\keras\engine\training.py", line 804, in _standardize_user_data exception_prefix='target') File "D:\software\python\lib\site-packages\tensorflow\python\keras_impl\keras\engine\training_utils.py", line 192, in standardize_input_data ' but got array with shape ' + str(data_shape)) ValueError: Error when checking target: expected activation_50 to have shape (173,) but got array with shape (3,)

navdeep1604 commented 5 years ago

Any luck, getting this error?

OlafenwaMoses commented 5 years ago

Hello, you add 3 items in the train folder and 4 items in the test folder. They must the same number of items with the same folder name.

Found 173 images belonging to 3 classes. Found 240 images belonging to 4 classes.

Also, use at least _numexperiments=20 in your train function.