Object detection with prediction training

Hi there,

I have successfully trained a predictor model - so with no labels using ModelTraining class.

Currently I can use CustomImagePrediction.predictImage() to return a value of what it thinks is in the picture.

I want to be able to detect the location of the object in the image, not just what it thinks it is. This functionality is in CustomObjectDetection but this is obviously a different class (gives a no label error as it requires the other training method, with the labels).

Is it possible to achieve this with a predictor model?

Thank you

If I understand your question, you are trying to detect and identify an object without drawing the model on the image?

Yeah, however I’ve ended up just labeling them.

I’ve run into another problem. When I train using the DetectModelTrainer() class, on the first epoch at 839/840 I’m getting this error:

libpng warning: iCCP: known incorrect sRGB profile
Cannot find  crab\validation\images\533.257297283.jpg
Traceback (most recent call last):
  File "train.py", line 7, in <module>
  File "C:\Users\cl\AppData\Local\Programs\Python\Python36\lib\site-packages\imageai\Detection\Custom\__init__.py", line 291, in trainModel
  File "C:\Users\cl\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\cl\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\engine\training.py", line 1732, in fit_generator
  File "C:\Users\cl\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\engine\training_generator.py", line 242, in fit_generator
  File "C:\Users\cl\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\cl\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\engine\training.py", line 1791, in evaluate_generator
  File "C:\Users\cl\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\engine\training_generator.py", line 365, in evaluate_generator
    generator_output = next(output_generator)
  File "C:\Users\cl\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\utils\data_utils.py", line 625, in get
  File "C:\Users\cl\AppData\Local\Programs\Python\Python36\lib\site-packages\six.py", line 696, in reraise
    raise value
  File "C:\Users\cl\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\utils\data_utils.py", line 610, in get
    inputs = future.get(timeout=30)
  File "C:\Users\cl\AppData\Local\Programs\Python\Python36\lib\multiprocessing\pool.py", line 644, in get
    raise self._value
  File "C:\Users\cl\AppData\Local\Programs\Python\Python36\lib\multiprocessing\pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "C:\Users\cl\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\utils\data_utils.py", line 406, in get_index
    return _SHARED_SEQUENCES[uid][i]
  File "C:\Users\cl\AppData\Local\Programs\Python\Python36\lib\site-packages\imageai\Detection\Custom\generator.py", line 73, in __getitem__
    img, all_objs = self._aug_image(train_instance, net_h, net_w)
  File "C:\Users\cl\AppData\Local\Programs\Python\Python36\lib\site-packages\imageai\Detection\Custom\generator.py", line 163, in _aug_image
    image = image[:,:,::-1] # RGB image
**TypeError: 'NoneType' object is not subscriptable**

Is this just because it cannot find that image? Or is it something else? I’m just wondering because it’s such a long time until I can test the error with the image found.

Is there any way to carry on from the same position after an error?


For this error, since it happens at the last step of the epoch, it because you have a .xml file in your validation/annotations folder with the name 533.257297283.xml but the corresponding image 533.257297283.jpg in the validation/images is missing…

1 Like