Sadaf Shafi
Sadaf Shafi

Reputation: 1458

YoloV8 Label file when there is no bounding box?

I wanted to train my yolo model and see if I can detect pneumonia in images So the images I have of X ray and the one which has pneumonia , its labels look like the following

1 0.2 0.23 0.32 0.23

Where first value is lable and rest four are the coordinates

now when the lable is 0, ie. no bounding box, label text file would look as following

0

Now the problem with this is YoLo would throw an error, as follows

/opt/conda/lib/python3.7/site-packages/ultralytics/yolo/data/dataset.py in get_labels(self)
    157         # Check if the dataset is all boxes or all segments
    158         lengths = ((len(lb['cls']), len(lb['bboxes']), len(lb['segments'])) for lb in labels)
--> 159         len_cls, len_boxes, len_segments = (sum(x) for x in zip(*lengths))
    160         if len_segments and len_boxes != len_segments:
    161             LOGGER.warning(

ValueError: not enough values to unpack (expected 3, got 0)

and before this error I get the following warning

WARNING ⚠️ /content/datasets/coco128/images/train2017/000000000009.jpg: ignoring corrupt image/label: labels require 5 columns, 1 columns detected

ChatGPT suggests delete the files with label of 0, but I am afraid my model has to classify if there is pneumonia and then show a place if there is and I am afraid will it detect well if it is not trained on the images which arent with Pneumonia

How do we feed data to our YoloV8 model when no bounding boxes are present ?

Ps: I am using Ultralytics library

Thanks

Upvotes: 2

Views: 1209

Answers (1)

Alex Ramses
Alex Ramses

Reputation: 577

According to the Ultralytics documentation here

If there are no objects in an image, no *.txt file is required.

I think you should just remove the .txt file for any image with no objects.

Upvotes: 3

Related Questions