Ejemplo n.º 1
0
def main():
    pp = pprint.PrettyPrinter(indent=4)

    img_path = args.img_path
    print("imageee path",img_path)
    label_path = args.label_path
    img_type = args.img_type
    datasets = args.datasets
    cls_list = args.cls_list_file

    result = None
    data = None

    if datasets == "COCO":
        coco = COCO()
        result, data = coco.parse(label_path)
    elif datasets == "VOC":
        voc = VOC()
        result, data = voc.parse(label_path)
    elif datasets == "UDACITY":
        udacity = UDACITY()
        result, data = udacity.parse(label_path, img_path)
    elif datasets == "KITTI":
        kitti = KITTI()
        result, data = kitti.parse(label_path, img_path, img_type=img_type)
    elif datasets == "YOLO":
        yolo =YOLO(os.path.abspath(cls_list))
        result, data = yolo.parse(label_path, img_path, img_type=img_type)

    if result is True:
        for key in data:

            filepath = "".join([img_path, key, img_type])

            im = Image.open(filepath)

            draw = ImageDraw.Draw(im)
            print("data['{}']: ".format(key), end="")
            pp.pprint(data[key])
            print("num_object : {}".format(data[key]["objects"]["num_obj"]))
            for idx in range(0, int(data[key]["objects"]["num_obj"])):
                print("idx {}, name : {}, bndbox :{}".format(idx, data[key]["objects"][str(idx)]["name"], data[key]["objects"][str(idx)]["bndbox"]))

                x0 = data[key]["objects"][str(idx)]["bndbox"]["xmin"]
                y0 = data[key]["objects"][str(idx)]["bndbox"]["ymin"]
                x1 = data[key]["objects"][str(idx)]["bndbox"]["xmax"]
                y1 = data[key]["objects"][str(idx)]["bndbox"]["ymax"]

                draw.rectangle(((x0,y0), (x1,y1)), outline='#00ff88')
                draw.text((x0,y0), data[key]["objects"][str(idx)]["name"])

            del draw
            print("===============================================================================================\n\n")
            plt.imshow(im)
            plt.show()
            plt.clf()
            im.close()

    else:
        print("return value : {}, msg : {}, args: {}".format(result, data, args))
def main(config):
    if config["no_label"]:
        make_image_path(config)
        return
    coco = COCO()
    print(config["label"])
    print(config["img_path"])
    flag, data, cls_hierarchy = coco.parse(config["label"], config["img_path"])
    yolo = YOLO(os.path.abspath(config["cls_list"]),
                cls_hierarchy=cls_hierarchy)

    if flag == True:
        flag, data = yolo.generate(data)

        if flag == True:
            flag, data = yolo.save(data, config["output_path"],
                                   config["img_path"], config["img_type"],
                                   config["manifest_path"],
                                   config["manifest_name"])

            if flag == False:
                print("Saving Result : {}, msg : {}".format(flag, data))
        else:
            print("YOLO Generating Result : {}, msg : {}".format(flag, data))
    else:
        print("COCO Parsing Result : {}, msg : {}".format(flag, data))
Ejemplo n.º 3
0
def main(config):

    if config["datasets"] == "VOC":
        voc = VOC()
        yolo = YOLO(os.path.abspath(config["cls_list"]))

        flag, data = voc.parse(config["label"])

        if flag == True:

            flag, data = yolo.generate(data)
            if flag == True:
                flag, data = yolo.save(data, config["output_path"], config["img_path"] ,
                                       config["img_type"], config["records_path"])

                if flag == False:
                    print("Saving Result : {}, msg : {}".format(flag, data))

            else:
                print("YOLO Generating Result : {}, msg : {}".format(flag, data))


        else:
            print("VOC Parsing Result : {}, msg : {}".format(flag, data))


    elif config["datasets"] == "COCO":
        coco = COCO()
        yolo = YOLO(os.path.abspath(config["cls_list"]))

        flag, data = coco.parse(config["label"])

        if flag == True:
            flag, data = yolo.generate(data)

            if flag == True:
                flag, data = yolo.save(data, config["output_path"], config["img_path"],
                                        config["img_type"], config["records_path"])

                if flag == False:
                    print("Saving Result : {}, msg : {}".format(flag, data))

            else:
                print("YOLO Generating Result : {}, msg : {}".format(flag, data))

        else:
            print("COCO Parsing Result : {}, msg : {}".format(flag, data))

    else:
        print("Unkwon Datasets")
Ejemplo n.º 4
0
def main(config):

    if config["datasets"] == "VOC":
        voc = VOC()
        yolo = YOLO(os.path.abspath(config["cls_list"]))

        flag, data = voc.parse(config["label"])

        if flag == True:

            flag, data = yolo.generate(data)
            if flag == True:
                flag, data = yolo.save(data, config["output_path"],
                                       config["img_path"], config["img_type"],
                                       config["manipast_path"])

                if flag == False:
                    print("Saving Result : {}, msg : {}".format(flag, data))

            else:
                print("YOLO Generating Result : {}, msg : {}".format(
                    flag, data))

        else:
            print("VOC Parsing Result : {}, msg : {}".format(flag, data))

    elif config["datasets"] == "COCO":
        coco = COCO()
        yolo = YOLO(os.path.abspath(config["cls_list"]))

        flag, data = coco.parse(config["label"])

        if flag == True:
            flag, data, data_annotation = yolo.generate(data)

            if flag == True:
                flag, data = yolo.save_annotation(data, data_annotation,
                                                  config["output_path"],
                                                  config["img_path"],
                                                  config["img_type"],
                                                  config["manipast_path"])

                if flag == False:
                    print("Saving Result : {}, msg : {}".format(flag, data))

            else:
                print("YOLO Generating Result : {}, msg : {}".format(
                    flag, data))

        else:
            print("COCO Parsing Result : {}, msg : {}".format(flag, data))

    elif config["datasets"] == "UDACITY":
        udacity = UDACITY()
        yolo = YOLO(os.path.abspath(config["cls_list"]))

        flag, data = udacity.parse(config["label"])

        if flag == True:
            flag, data = yolo.generate(data)

            if flag == True:
                flag, data = yolo.save(data, config["output_path"],
                                       config["img_path"], config["img_type"],
                                       config["manipast_path"])

                if flag == False:
                    print("Saving Result : {}, msg : {}".format(flag, data))

            else:
                print("UDACITY Generating Result : {}, msg : {}".format(
                    flag, data))

        else:
            print("COCO Parsing Result : {}, msg : {}".format(flag, data))

    elif config["datasets"] == "KITTI":
        kitti = KITTI()
        yolo = YOLO(os.path.abspath(config["cls_list"]))

        flag, data = kitti.parse(config["label"],
                                 config["img_path"],
                                 img_type=config["img_type"])

        if flag == True:
            flag, data = yolo.generate(data)

            if flag == True:
                flag, data = yolo.save(data, config["output_path"],
                                       config["img_path"], config["img_type"],
                                       config["manipast_path"])

                if flag == False:
                    print("Saving Result : {}, msg : {}".format(flag, data))

            else:
                print("YOLO Generating Result : {}, msg : {}".format(
                    flag, data))

        else:
            print("KITTI Parsing Result : {}, msg : {}".format(flag, data))

    else:
        print("Unkwon Datasets")
Ejemplo n.º 5
0
def main(config):

    if config["datasets"] == "VOC":
        voc = VOC()
        yolo = YOLO(os.path.abspath(config["cls_list"]))

        flag, data = voc.parse(config["label"])

        if flag == True:

            flag, data = yolo.generate(data)
            if flag == True:
                flag, data = yolo.save(data, config["output_path"],
                                       config["img_path"], config["img_type"],
                                       config["manifest_path"])

                if flag == False:
                    print("Saving Result : {}, msg : {}".format(flag, data))

            else:
                print("YOLO Generating Result : {}, msg : {}".format(
                    flag, data))

        else:
            print("VOC Parsing Result : {}, msg : {}".format(flag, data))

    elif config["datasets"] == "COCO":
        coco = COCO()

        keep = {
            "person", "bicycle", "car", "motorcycle", "bus", "train", "truck"
        }

        flag, data, cls_hierarchy = coco.parse(config["label"],
                                               config["img_path"],
                                               keep=keep)

        data = sampleDataset(data, config["num_samples"], keep, config["seed"])

        yolo = YOLO(os.path.abspath(config["cls_list"]),
                    cls_hierarchy=cls_hierarchy)

        if flag == True:
            flag, data = yolo.generate(data)

            if flag == True:
                flag, data = yolo.save(data, config["output_path"],
                                       config["img_path"], config["img_type"],
                                       config["manifest_path"])

                if flag == False:
                    print("Saving Result : {}, msg : {}".format(flag, data))

            else:
                print("YOLO Generating Result : {}, msg : {}".format(
                    flag, data))

        else:
            print("COCO Parsing Result : {}, msg : {}".format(flag, data))

    elif config["datasets"] == "UDACITY":
        udacity = UDACITY()
        yolo = YOLO(os.path.abspath(config["cls_list"]))

        flag, data = udacity.parse(config["label"])

        if flag == True:
            flag, data = yolo.generate(data)

            if flag == True:
                flag, data = yolo.save(data, config["output_path"],
                                       config["img_path"], config["img_type"],
                                       config["manifest_path"])

                if flag == False:
                    print("Saving Result : {}, msg : {}".format(flag, data))

            else:
                print("UDACITY Generating Result : {}, msg : {}".format(
                    flag, data))

        else:
            print("COCO Parsing Result : {}, msg : {}".format(flag, data))

    elif config["datasets"] == "KITTI":
        kitti = KITTI()
        yolo = YOLO(os.path.abspath(config["cls_list"]))

        flag, data = kitti.parse(config["label"],
                                 config["img_path"],
                                 img_type=config["img_type"])

        if flag == True:
            flag, data = yolo.generate(data)

            if flag == True:
                flag, data = yolo.save(data, config["output_path"],
                                       config["img_path"], config["img_type"],
                                       config["manifest_path"])

                if flag == False:
                    print("Saving Result : {}, msg : {}".format(flag, data))

            else:
                print("YOLO Generating Result : {}, msg : {}".format(
                    flag, data))

        else:
            print("KITTI Parsing Result : {}, msg : {}".format(flag, data))

    else:
        print("Unkwon Datasets")