Traffic objects detection

Hi everyone,

I’m a real beginner into AI, so I apologize beforehand for any dummy remarks which I may have done.

I have a requirement to detect traffic objects such as traffic lights, signs and crossing lines from a dataset of images.
I already have a relevant dataset for training (around 300 images per object) and a little less for testing, however, these aren’t yet all labeled (I’m using Labelimg for it - plenty of time being invested there, btw).
The dataset is organized in the directory hierarchy suggested by the guide [1]. Naming standard is the same for all images (e.g. image(1).jpg, image(2).jpg…)

Now, I’ve successfully followed the car image recognition example [2], so I believe that all dependencies were installed up to now (I’m running from Eclipse).

Right now, I have two concerns:

  1. Will my images need to have all the same width and height?
  2. Since I don’t have plenty of GPU power (only a 1GB Intel GPU), what would be optimal parameters in my case?

I’d deeply appreciate if anyone could throw some light on this.
Kindly let me know if any info is required from my end.

All the best.
Pablo

[1] https://github.com/OlafenwaMoses/ImageAI/blob/master/imageai/Detection/Custom/CUSTOMDETECTIONTRAINING.md#preparingdataset
[2] https://medium.com/@guymodscientist/image-prediction-with-10-lines-of-code-3266f4039c7a

An update:
After running the following training code, the list of parameters is given but the below errors are thrown on Eclipse console:

from imageai.Prediction.Custom import ModelTraining
model_trainer = ModelTraining()
model_trainer.setModelTypeAsResNet()
model_trainer.setDataDirectory(“traffic_dataset”)
model_trainer.trainModel(num_objects=3, num_experiments=200, enhance_data=True, batch_size=4, show_network_summary=True)

==================================================================================================
Total params: 23,593,859
Trainable params: 23,540,739
Non-trainable params: 53,120


WARNING:tensorflow:period argument is deprecated. Please use save_freq to specify the frequency in number of samples seen.
Using Enhanced Data Generation
Found 440 images belonging to 5 classes.
Found 59 images belonging to 2 classes.
JSON Mapping for the model classes saved to traffic_dataset\json\model_class.json
Number of experiments (Epochs) : 200
Epoch 1/200

Traceback (most recent call last):
File “C:\Users\d8432\Desktop\Personal\Aulas\Elaboracao de Projetos\ImageAI-master\ImageAI-master\imageai\training.py”, line 5, in
model_trainer.trainModel(num_objects=3, num_experiments=200, enhance_data=True, batch_size=4, show_network_summary=True)
File “C:\Users\d8432\AppData\Local\Programs\Python\Python36\lib\site-packages\imageai\Prediction\Custom_init_.py”, line 342, in trainModel
validation_steps=int(num_test / batch_size), callbacks=[checkpoint, lr_scheduler, tensorboard])
File “C:\Users\d8432\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\python\keras\engine\training.py”, line 1297, in fit_generator
steps_name=‘steps_per_epoch’)
File “C:\Users\d8432\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\python\keras\engine\training_generator.py”, line 265, in model_iteration
batch_outs = batch_function(*batch_data)
File “C:\Users\d8432\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\python\keras\engine\training.py”, line 992, in train_on_batch
extract_tensors_from_dataset=True)
File “C:\Users\d8432\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\python\keras\engine\training.py”, line 2538, in _standardize_user_data
y, self._feed_loss_fns, feed_output_shapes)
File “C:\Users\d8432\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\python\keras\engine\training_utils.py”, line 743, in check_loss_and_target_compatibility
’ while using as loss ' + loss_name + '. ’
ValueError: A target array with shape (4, 5) was passed for an output of shape (None, 3) while using as loss categorical_crossentropy. This loss expects targets to have the same shape as the output.

Does anybody know the reason for these errors? Is it related to the parameters that I’ve defined?

@pablomoraes I observe that you are using the training code for prediction and not detection. Visit the link below to see the correct code.

Also, you might want to use Google Colab for your model training.