Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么标注得到的坐标值会超过图像边界 #833

Open
1 task done
Ggstuddu opened this issue Feb 23, 2025 · 10 comments
Open
1 task done

为什么标注得到的坐标值会超过图像边界 #833

Ggstuddu opened this issue Feb 23, 2025 · 10 comments
Labels
bug Something isn't working

Comments

@Ggstuddu
Copy link

Search before asking

  • I have searched the X-AnyLabeling Docs and issues and found no similar questions.

Question

我使用2.5.3版本的anylabeling进行标注,发觉通过软件转换后的yolo标签有出现坐标值为-1的情况,然后通过排查发觉是在标注的时候得到的json标签文件里的坐标就有问题,得到的坐标(640.4121557454889)超过了图像的边界(640)。
我尝试手动调整一下框的位置,但是更新后的json标签文件仍存在坐标越界问题,请问这个情况应该如何解决?
以下是一个有问题的完整的json标签文件:

{
  "version": "2.5.3",
  "flags": {},
  "shapes": [
    {
      "kie_linking": [],
      "label": "defect_dent",
      "score": null,
      "points": [
        [
          478.68345323741005,
          459.56834532374097
        ],
        [
          512.0863309352518,
          459.56834532374097
        ],
        [
          512.0863309352518,
          484.59712230215825
        ],
        [
          478.68345323741005,
          484.59712230215825
        ]
      ],
      "group_id": null,
      "description": null,
      "difficult": false,
      "shape_type": "rectangle",
      "flags": {},
      "attributes": {}
    },
    {
      "kie_linking": [],
      "label": "defect_dent",
      "score": null,
      "points": [
        [
          63.83950617283952,
          28.33333333333339
        ],
        [
          153.64197530864203,
          28.33333333333339
        ],
        [
          153.64197530864203,
          106.33333333333337
        ],
        [
          63.83950617283952,
          106.33333333333337
        ]
      ],
      "group_id": null,
      "description": null,
      "difficult": false,
      "shape_type": "rectangle",
      "flags": {},
      "attributes": {}
    },
    {
      "kie_linking": [],
      "label": "defect_dent",
      "score": null,
      "points": [
        [
          362.90123456790127,
          4.0
        ],
        [
          458.0,
          4.0
        ],
        [
          458.0,
          49.320987654321044
        ],
        [
          362.90123456790127,
          49.320987654321044
        ]
      ],
      "group_id": null,
      "description": null,
      "difficult": false,
      "shape_type": "rectangle",
      "flags": {},
      "attributes": {}
    },
    {
      "kie_linking": [],
      "label": "defect_dent",
      "score": null,
      "points": [
        [
          557.3170731707318,
          372.19512195121956
        ],
        [
          574.3902439024391,
          372.19512195121956
        ],
        [
          574.3902439024391,
          390.2439024390244
        ],
        [
          557.3170731707318,
          390.2439024390244
        ]
      ],
      "group_id": null,
      "description": "",
      "difficult": false,
      "shape_type": "rectangle",
      "flags": {},
      "attributes": {}
    },
    {
      "kie_linking": [],
      "label": "defect_dirt",
      "score": null,
      "points": [
        [
          372.3570750237418,
          529.7454890788223
        ],
        [
          640.4311490978159,
          529.7454890788223
        ],
        [
          640.4311490978159,
          640.4121557454889
        ],
        [
          372.3570750237418,
          640.4121557454889
        ]
      ],
      "group_id": null,
      "description": "",
      "difficult": false,
      "shape_type": "rectangle",
      "flags": {},
      "attributes": {}
    },
    {
      "kie_linking": [],
      "label": "defect_dent",
      "score": null,
      "points": [
        [
          462.28395061728395,
          556.1111111111111
        ],
        [
          491.2962962962963,
          556.1111111111111
        ],
        [
          491.2962962962963,
          580.8024691358025
        ],
        [
          462.28395061728395,
          580.8024691358025
        ]
      ],
      "group_id": null,
      "description": "",
      "difficult": false,
      "shape_type": "rectangle",
      "flags": {},
      "attributes": {}
    },
    {
      "kie_linking": [],
      "label": "defect_long_strip",
      "score": null,
      "points": [
        [
          146.23456790123458,
          23.395061728395117
        ],
        [
          580.1851851851852,
          23.395061728395117
        ],
        [
          580.1851851851852,
          132.6543209876544
        ],
        [
          146.23456790123458,
          132.6543209876544
        ]
      ],
      "group_id": null,
      "description": "",
      "difficult": false,
      "shape_type": "rectangle",
      "flags": {},
      "attributes": {}
    }
  ],
  "imagePath": "new_21.jpg",
  "imageData": null,
  "imageHeight": 640,
  "imageWidth": 640,
  "description": ""
}

Additional

No response

@Ggstuddu Ggstuddu added the question Further information is requested label Feb 23, 2025
@CVHub520
Copy link
Owner

Hi, @Ggstuddu:

Thanks for your feedback! Before I can provide a detailed solution, could you tell me are you using the default built-in model provided by X-AnyLabeling, or a custom-trained one?

If you could provide these details, I can better diagnose the root cause and suggest appropriate fixes for the coordinate prediction issue.

@Ggstuddu
Copy link
Author

你好,十分感谢你的回复。
我使用的是你们提供的模型,下载链接是:https://github.com/CVHub520/X-AnyLabeling/releases/download/v0.1.0/yolov8s.onnx
在模型自动跑然后运行了之后我也试过手动调整bbox,但更新后的json文件的坐标还是越界。

@CVHub520
Copy link
Owner

The official built-in model is trained on the COCO dataset weights. As you provided in the label file example above, it includes categories such as defect_dent and defect_dirt. To my knowledge, these are not part of the 80 categories defined by COCO. Could there be some misunderstanding here?

@Ggstuddu
Copy link
Author

对不起,我记混了,记成另外一个项目了,这个越界的框应该是我自己手动框的,或者是通过yolo模型预测得到的txt导入得到的,具体是哪一个我不太记得,因为如果yolo模型预测的不准的话我会自己手动框一下。
并没有用到你们提供的onnx文件,很抱歉我记错了。

@CVHub520
Copy link
Owner

CVHub520 commented Feb 23, 2025

If you manually draw a rectangle box, the maximum coordinate value is (image_height-1, image_width-1). Specifically, you can load any new image and try drawing a rectangle box.

Therefore, this is most likely due to a deviation in the coordinates output by your custom model. But, don't worry, you can just add a simple truncation logic here.

@Ggstuddu
Copy link
Author

感谢您的建议,我觉得应该是可行的,我明天会添加截断功能并且测试一下。

@Ggstuddu
Copy link
Author

今天再进行了测试,发觉问题并没有完全解决:
为了确保标签坐标不会越界,首先要确保标签数据导入并转换成json文件的时候不会越界,目前基于已有的yolo模型获得json标签文件有两种方式:
①通过anylabeling提供的自动标注功能:在这个情况为了确保不要越界,需要在anylabeling/services/auto_labeling/base/yolo.py的create_rectangle_shape()函数添加截断功能;
②通过模型预测得到标签txt文件,然后通过“导入yolo水平框”功能导入:在这个情况为了确保不要越界,需要在anylabeling/views/labeling/label_converter.py的yolo_to_custom()函数添加截断功能。
经测试,自己之前确实会在导入和转换成json文件时直接产生越界的bbox坐标,但在对应的区域添加了截断功能后导入生成的json文件的坐标已经不会有越界的问题了。
但是后面发现在将bbox往图像边界拖拽时仍有可能会在json标签文件那里产生越界的坐标值,可能也需要在拖拽bbox的代码添加截断的功能。

@Ggstuddu Ggstuddu reopened this Feb 24, 2025
@CVHub520
Copy link
Owner

Regarding the possibility of generating out-of-bounds coordinate values in the JSON label file when dragging a rectangle towards the canvas boundary, would you be able to record a video demonstrating this? I have tested this multiple times and have not encountered the situation.

@Ggstuddu
Copy link
Author

我在家里的电脑复现了一下,家里用的anylabeling的版本是2.4.4,仍有出现拖拽后越界的情况,以下是视频:

2025-02-24-20-53-59.mp4

@CVHub520
Copy link
Owner

Thank you for the detailed feedback. It does appear there is an overflow of coordinate values.

@CVHub520 CVHub520 added bug Something isn't working and removed question Further information is requested labels Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants