Use predict on large image

Hi!

I have trained a U-Net on image chip of 250x250 pixels, nom I’m trying to make a large image (satellite) go through the model but I get a 250x250 result. I understand why i get this result, but before writing code to split my images, i was wondering if anyone had a simpler solution than working with numpy array?

Thank yuo in advance

1 Like

Same problem with aerial images.

Did you have found a solution ?

Perhaps it will be nice to have some high level function to automate the process :

  • Split raster in tiles
  • predict on each tlie
  • fusion the tiles to one big raster
  • raster to shapefile (optional)

This kaggle post shows that it is possible to predict on a full image using a model that was trained on chips :

I am currently trying to get it running with fast.ai

1 Like

The typical approach is to use sliding window (sliced) inference. There are several implementations online but I recommend checking out GitHub - obss/sahi: Sliced/tiled inference + image slicing + interactive ui + error analysis plots + MMDetection/Detectron2/YOLOv5/Torchvision/HuggingFace support

2 Likes

I faced similar problem with binary segmentation model once which I wanted to use to crop original images in the dataset. So I trained the model on 4 times small images. The predicted masks came out to be of the same 4x small dimensions. I needed these mask to crop the original images which is huge, not the smaller version used to train the model.

What worked for me was to resize the predicted mask using the dimensions of the original image. This might work for you too.