YoloV8标签文件中没有边界框时怎么办?

huangapple go评论95阅读模式
英文:

YoloV8 Label file when there is no bounding box?

问题

以下是代码部分的翻译:

我想要训练我的yolo模型,看看能否检测图像中的肺炎
所以我有X射线图像,其中有肺炎的图像,其标签如下

    1 0.2 0.23 0.32 0.23

其中第一个值是标签,其余四个是坐标

现在,当标签为0,即没有边界框时,标签文本文件将如下所示

    0

现在,这个问题是YoLo会引发错误,如下所示

    /opt/conda/lib/python3.7/site-packages/ultralytics/yolo/data/dataset.py中的get_labels(self)
        157        # 检查数据集是否全是框或全是段
        158        长度 = ((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和len_boxes!= len_segments:
        161            LOGGER警告(

    ValueError:没有足够的值来解包(期望3个,得到0个)

在出现此错误之前,我收到以下警告

    警告⚠️ /content/datasets/coco128/images/train2017/000000000009.jpg:忽略损坏的图像/标签:标签需要5列,检测到1列

ChatGPT建议删除标签为0的文件,但我担心我的模型必须分类是否存在肺炎,然后显示是否存在的位置,我担心如果没有训练模型的不带肺炎的图像,它是否能够检测得好

当没有边界框存在时,如何向YoloV8模型提供数据?

附言:我正在使用Ultralytics库

这是代码部分的翻译,请告诉我是否需要其他内容的翻译。

英文:

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

答案1

得分: 2

根据Ultralytics文档这里

> 如果图像中没有对象,不需要*.txt文件。

我认为你应该删除没有对象的任何图像的.txt文件。

英文:

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.

huangapple
  • 本文由 发表于 2023年4月11日 01:31:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75979297.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定