def main():
    if len(sys.argv) < 5:
        print('Please pass <TensorFlow record path> <Number of classes> <"cpu"/"gpu"> <batch_size>')
        exit(0)
    imagePath = sys.argv[1]
    numClasses = int(sys.argv[2])
    if(sys.argv[3] == "cpu"):
        raliCPU = True
    else:
        raliCPU = False
    bs = int(sys.argv[4])
    nt = 1
    di = 0
    cropSize = 320
    TFRecordReaderType = 1
    featureKeyMap = {
        'image/encoded': 'image/encoded',
        'image/class/label': 'image/object/class/label',
        'image/class/text': 'image/object/class/text',
        'image/object/bbox/xmin': 'image/object/bbox/xmin',
        'image/object/bbox/ymin': 'image/object/bbox/ymin',
        'image/object/bbox/xmax': 'image/object/bbox/xmax',
        'image/object/bbox/ymax': 'image/object/bbox/ymax',
        'image/filename': 'image/filename'
    }

    pipe = HybridPipe(feature_key_map=featureKeyMap, tfrecordreader_type=TFRecordReaderType,
                      batch_size=bs, num_threads=nt, device_id=di, data_dir=imagePath, crop=cropSize, rali_cpu=raliCPU)
    pipe.build()

    imageIterator = RALIIterator(pipe)

    for i, (images_array, bboxes_array, labels_array, num_bboxes_array) in enumerate(imageIterator, 0):
        images_array = np.transpose(images_array, [0, 2, 3, 1])
        print("RALI augmentation pipeline - Processing batch %d....." % i)

        for element in list(range(bs)):
            print("Processing image %d....." % element)
            features_dict = {
                "image": images_array[element],
                "true_image_shape": np.array([len(images_array[element]), len(images_array[element, 0]), len(images_array[element, 0, 0])])
            }
            labels_dict = {
                "num_groundtruth_boxes": num_bboxes_array[element],
                "groundtruth_boxes": bboxes_array[element],
                "groundtruth_classes": get_onehot(labels_array[element], numClasses),
                "groundtruth_weights": get_weights(num_bboxes_array[element])
            }
            processed_tensors = (features_dict, labels_dict)
            print("\nPROCESSED_TENSORS:\n", processed_tensors)
        print("\n\nPrinted first batch with", (bs), "images!")
        break
    imageIterator.reset()
def main():
    if len(sys.argv) < 5:
        print(
            'Please pass the <TensorFlowrecord> <cpu/gpu> <batch_size> <oneHotLabels=0/1>'
        )
        exit(0)
    imagePath = sys.argv[1]
    if (sys.argv[2] == "cpu"):
        raliCPU = True
    else:
        raliCPU = False
    bs = int(sys.argv[3])
    oneHotLabel = int(sys.argv[4])
    nt = 1
    di = 0
    cropSize = 224
    TFRecordReaderType = 0
    featureKeyMap = {
        'image/encoded': 'image/encoded',
        'image/class/label': 'image/class/label',
        'image/filename': 'image/filename'
    }

    pipe = HybridPipe(feature_key_map=featureKeyMap,
                      tfrecordreader_type=TFRecordReaderType,
                      batch_size=bs,
                      num_threads=nt,
                      device_id=di,
                      data_dir=imagePath,
                      crop=cropSize,
                      oneHotLabels=oneHotLabel,
                      rali_cpu=raliCPU)
    pipe.build()

    imageIterator = RALIIterator(pipe)
    for i, (images_array, labels_array) in enumerate(imageIterator, 0):
        print("\n\n", i)
        print("\nIMAGES ARRAY:\n", images_array)
        print("\nLABELS ARRAY:\n", labels_array)
    imageIterator.reset()