0

I'm using Yolov8 to perform image segmentation, and I want to retrain the network with images predicted by the network itself, but making corrections to the masks. That is, to make these corrections, I would like to know if there is any program that converts the labels generated by Yolo, in the prediction, to Labelme, for example. I know that labelme2yolo exists, but I would like the inverse conversion (yolo2labelme).

I found this code but I don't know if it works.

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)
    #######################

2 Answers2

0

You can install from pip by

pip install yolo2labelme

cli usage

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

for more details see PyPi or github

0

You can convert with pascal-voc

pip install 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)