JSON2YOLO icon indicating copy to clipboard operation
JSON2YOLO copied to clipboard

merge_multi_segment

Open sarasilva-digitalsense opened this issue 1 year ago • 2 comments

Hello! I'm trying to change the general_json2yolo script for my case-use and I've run into a problem I haven't been able to solve so far. Basically, I don't really understand what the function merge_multi_segment does, or how the segment information should come for it to work. This is how the function is called:

s = merge_multi_segment(ann['segmentation'])

and ann['segmentation'] for me is a list such as:

['199', '127', '198', '128', '196', '128', '195', '129', '191', '129', '190', '130', '185', '130', '184', '131', '177', '131', '175', '133', '169', '133', '166', '136', '165', '136', '162', '139', '162', '141', '163', '142', '180', '142', '181', '141', '196', '141', '197', '142', '197', '144', '196', '145', '196', '147', '195', '148', '195', '149', '194', '150', '194', '151', '193', '152', '193', '153', '204', '153', '205', '152', '206', '152', '208', '150', '209', '150', '212', '147', '212', '142', '211', '141', '211', '139', '208', '136', '208', '135', '207', '134', '208', '133', '217', '133', '218', '134', '219', '134', '220', '133', '220', '132', '221', '131', '221', '130', '220', '129', '220', '128', '219', '127']

Besides from changing that into integers, what should i take into account, and what are the segments that the merge_multi_segment refers to

sarasilva-digitalsense avatar Jun 27 '23 13:06 sarasilva-digitalsense

Related issue. https://github.com/ultralytics/yolov5/issues/11476#issuecomment-1537281864

Using the JSON2YOLO script, you can merge multiple polygons in the COCO format into a polygon in the YOLOv5/v8 format.

ryouchinsa avatar Oct 25 '23 13:10 ryouchinsa

The merge_multi_segment function in the JSON2YOLO script is designed to merge multiple polygons in the COCO format into a single polygon in the YOLOv5/v8 format. When calling the function, ensure that the input segmentation data is in the appropriate format, typically as a list of coordinates. Additionally, the function expects the input segments to form a continuous sequence representing the polygon vertices. Be sure to convert the input data into integer format as well.

glenn-jocher avatar Nov 09 '23 18:11 glenn-jocher