Train a model using 3d float tensors instead of jpg images?

Hello, as the title says I am trying to train a model using a dataset of 3d float tensors as .npy files. I am following the tutorial of the object detection api (Training Custom Object Detector — TensorFlow 2 Object Detection API tutorial documentation)

My problem is that I cannot generate the record files. Running the script i get an error that says
“cannot identify image file %r” % (filename if filename else fp)
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x0000023864E34168>.

which makes sense, really. I tried to work around this by editing the script and changing line 118, where instead of I put np.load. This successfully creates the record files. But when I try to train the model I get a different error before training starts:

tensorflow.python.framework.errors_impl.InvalidArgumentError: assertion failed: [Unable to decode bytes as JPEG, PNG, GIF, or BMP]

Note that when I follow the exact same steps when using a dataset of .jpg files everything works fine. So how can I adapt the code to work directly with the tensors, without converting to and from image files?