question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Training on own data

See original GitHub issue

Hey. I use my own data to teach this model. I use aerial photographs on which there are cars. This is how the markup file looks like:

<annotation>
<folder> </folder>
<filename>57.JPG</filename>
<source> </source>
<owner> </owner>
<size><width>1024</width>
<height>600</height>
<depth>3</depth></size>
<segmented>0</segmented>
<object><name>truck_trail</name>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox><xmin>939</xmin>
<ymin>345</ymin>
<xmax>1024</xmax>
<ymax>403</ymax>
</bndbox></object>

When an object is on the border of the image, an error occurs:

File "train.py", line 276, in <module>
    main()
  File "train.py", line 272, in main
    callbacks=callbacks,
  File "/usr/local/lib/python3.5/dist-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/keras/engine/training.py", line 2145, in fit_generator
    generator_output = next(output_generator)
  File "/usr/local/lib/python3.5/dist-packages/keras/utils/data_utils.py", line 770, in get
    six.reraise(value.__class__, value, value.__traceback__)
  File "/usr/local/lib/python3.5/dist-packages/six.py", line 693, in reraise
    raise value
  File "/usr/local/lib/python3.5/dist-packages/keras/utils/data_utils.py", line 635, in _data_generator_task
    generator_output = next(self._generator)
  File "../../keras_retinanet/preprocessing/generator.py", line 246, in __next__
    return self.next()
  File "../../keras_retinanet/preprocessing/generator.py", line 257, in next
    return self.compute_input_output(group)
  File "../../keras_retinanet/preprocessing/generator.py", line 241, in compute_input_output
    targets = self.compute_targets(image_group, annotations_group)
  File "../../keras_retinanet/preprocessing/generator.py", line 206, in compute_targets
    labels_group[index], regression_group[index] = self.anchor_targets(max_shape, annotations, self.num_classes(), mask_shape=image.shape)
  File "../../keras_retinanet/preprocessing/generator.py", line 192, in anchor_targets
    return anchor_targets_bbox(image_shape, boxes, num_classes, mask_shape, negative_overlap, positive_overlap, **kwargs)
  File "../../keras_retinanet/utils/anchors.py", line 67, in anchor_targets_bbox
    labels[positive_indices, boxes[positive_indices, 4].astype(int)] = 1
IndexError: index 7 is out of bounds for axis 1 with size 7
Exception ignored in: <bound method BaseSession.__del__ of <tensorflow.python.client.session.Session object at 0x7f9e07378278>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 696, in __del__
TypeError: 'NoneType' object is not callable

I understand that the error is due to the fact that the bounding rectangles somehow change during the augmentation process. How to solve this? 57

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Maxfashkocommented, Feb 1, 2018

Thank you! I twice announced a car and a truck

voc_classes = {
    "truck"         :0,
    'car'           :1,
    'car'           :2,
    'dashed_line'   :3,
    'bus'           :4,
    'truck'         :5,
    'car_trail'     :6,
    'truck_trail'   :7,
    'van_trail'     :8
}
1reaction
hgaisercommented, Feb 1, 2018

I think there’s something wrong with your classes. From your first post I see:

  File "../../keras_retinanet/utils/anchors.py", line 67, in anchor_targets_bbox
    labels[positive_indices, boxes[positive_indices, 4].astype(int)] = 1
IndexError: index 7 is out of bounds for axis 1 with size 7

That sounds like it is trying to access index 7 but the length of labels is 7.

If it’s easy to do, I advice to make your data in the CSV structure. It’s easier to make and easier to debug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Train Custom Data · ultralytics/yolov5 Wiki - GitHub
Creating a custom model to detect your objects is an iterative process of collecting and organizing images, labeling your objects of interest, ...
Read more >
How to Train YOLO v5 on a Custom Dataset - Paperspace Blog
This tutorial will show you how to implement and train YOLOv5 on your own custom dataset. Full Python code included.
Read more >
YOLOv7 Training on Custom Data? - Medium
In this article, we will focus on “Training of YOLOv7 on Custom Data”. You can follow mentioned steps below to train YOLOv7 on...
Read more >
Custom training: walkthrough | TensorFlow Core
This tutorial shows you how to train a machine learning model with a custom training loop to categorize penguins by species. In this...
Read more >
How to Train YOLOv5 On a Custom Dataset - Roboflow Blog
Training Custom YOLOv5 Detector · img: define input image size · batch: determine batch size · epochs: define the number of training epochs....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found