def read_list()

in ec2-spot-sagemaker-managed-spot-training/sagemaker-built-in-object-detection/tools/im2rec.py [0:0]


def read_list(path_in):
    with open(path_in) as fin:
        while True:
            line = fin.readline()
            if not line:
                break
            line = [i.strip() for i in line.strip().split("\t")]
            line_len = len(line)
            if line_len < 3:
                print(
                    "lst should at least has three parts, but only has %s parts for %s"
                    % (line_len, line)
                )
                continue
            try:
                item = [int(line[0])] + [line[-1]] + [float(i) for i in line[1:-1]]
            except Exception as e:
                print("Parsing lst met error for %s, detail: %s" % (line, e))
                continue
            yield item