Is your feature request related to a problem? Please describe.
I have been trying to use this library for the inference of TensorFlow binary and multiclass segmentation models. I am able to use the tiler object to perform the predictions. I have not been able to figure out how to leverage the merger for the following cases.
data_shape = 5000 x 3000 x 4
tile_shape = (256, 256, 4)
channel_dimension = 0
The output of the model can be either a batch of (N x 256 x 256 x 1) or (N x 256 x 256 x 6); where 6 is the number of classes.
ValueError: Passed data shape ([256 256 1]) does not fit expected tile shape ((256, 256, 4)).
Describe the solution you'd like
Would be great to have additional examples regarding similar use cases performing TensorFlow or PyTorch predictions.
Here is an example of what I have been trying:
model = tf.keras.models.load_model(model.hdf5)
image = rxr.open_rasterio(filename)
image = image.transpose("y", "x", "band")
print(image.shape)
tiler = Tiler(
data_shape=image.shape,
tile_shape=(256, 256, 4),
channel_dimension=2,
#overlap=0.50
)
# Calculate and apply extra padding, as well as adjust tiling parameters
#new_shape, padding = tiler.calculate_padding()
#tiler.recalculate(data_shape=new_shape)
#padded_image = np.pad(image, padding, mode="reflect")
merger = Merger(tiler=tiler)#, window="overlap-tile")
print(tiler)
for batch_id, batch in tiler(image, batch_size=512):
batch = model.predict(batch)
merger.add_batch(batch_id, 512, batch)
I am probably missing something, but would be nice to have it documented. Also, argmax option seems to be hardcoded for channel first images, which adds additional computational requirements when using channels last images. Any help would be appreciated.
Is your feature request related to a problem? Please describe.
I have been trying to use this library for the inference of TensorFlow binary and multiclass segmentation models. I am able to use the tiler object to perform the predictions. I have not been able to figure out how to leverage the merger for the following cases.
data_shape = 5000 x 3000 x 4
tile_shape = (256, 256, 4)
channel_dimension = 0
The output of the model can be either a batch of (N x 256 x 256 x 1) or (N x 256 x 256 x 6); where 6 is the number of classes.
ValueError: Passed data shape ([256 256 1]) does not fit expected tile shape ((256, 256, 4)).Describe the solution you'd like
Would be great to have additional examples regarding similar use cases performing TensorFlow or PyTorch predictions.
Here is an example of what I have been trying:
I am probably missing something, but would be nice to have it documented. Also, argmax option seems to be hardcoded for channel first images, which adds additional computational requirements when using channels last images. Any help would be appreciated.