def load_image()

in jetson_inference/artifacts/aws.greengrass.JetsonDLRImageClassification/1.0.0/inference.py [0:0]


def load_image(imgName):
    image_data = None

    sample_image = (mlRootPath + "/images/" + imgName).format(
        os.path.dirname(os.path.realpath(__file__)))
    if imgName.endswith(".jpg", -4,) or imgName.endswith(".png", -4,) or imgName.endswith(".jpeg", -5,):
        image = bytearray(open(sample_image, 'rb').read())
        image_data = cv2.imdecode(np.frombuffer(image, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
        image_data = cv2.resize(image_data, (224,224))
        print("loaded image:",imageName)
    elif imgName.endswith(".npy", -4,):
        # the shape for the resnet18 model is [1,3,224,224]
        image_data = np.load(sample_image).astype(np.float32)

    return image_data