如何将YOLO注释(.txt)转换为labelme?

问题描述 投票:0回答:2

我正在使用 Yolov8 执行图像分割,我想用网络本身预测的图像重新训练网络,但对掩模进行修正。也就是说,为了进行这些更正,我想知道是否有任何程序可以将预测中由 Yolo 生成的标签转换为 Labelme。我知道 labelme2yolo 存在,但我想要逆转换(yolo2labelme)。

我找到了这段代码,但我不知道它是否有效。

if __name__ == "__main__":
    #parameters
    paser = argparse.ArgumentParser()
    args = paser.parse_args("")
    
    ##### set params #####
    #input : yolo image, label path
    args.yolo_images_path = './yolo_data/images/'
    args.yolo_labels = './yolo_data/labels/'
    #class count
    args.yolo_nc = 80 
    #class names
    args.yolo_names = ['aeroplane', 'apple', 'backpack', ...]

    #output : labelme output path
    args.labelme_path = './output_yolo2labelme/'
    args.labelme_save_image = True #False #create jpg images in output path
    #######################


    #######################
    #start processing
    yolo2labelme_main(args)
    #######################
image-processing artificial-intelligence object-detection image-segmentation yolo
2个回答
0
投票

您可以通过 pip 安装

pip install yolo2labelme

cli 用法

yolo2labelme path/to/yoloDataset --out path/to/labelmeJsonDir

有关更多详细信息,请参阅 PyPigithub


0
投票

您可以使用 pascal-voc 进行转换

pip 安装 pascal-voc

import json

from pascal import annotation_from_yolo

label_map = {
    0: "person",
    1: "dog"
}

if __name__ == "__main__":
    ann = annotation_from_yolo(
        "000001.txt",
        label_map=label_map,
        img_w=353,
        img_h=500)

    labelme = ann.to_labelme()
    with open("000001.json", "w") as f:
        json.dump(labelme, f, indent=2)
© www.soinside.com 2019 - 2024. All rights reserved.