0
$\begingroup$

I'm using U-net architecture to build a segmentation task of image. During training I have image of size 256256 image. It works very well on the segmentation of same size 256256 or near to size 256*256 (by using torch for resizing). But while I'm using for bigger dimension it seems like model doesn't work at all.

# To resize the image of 1004* 942 
part1_path= '/Users/akshitdhillon/Documents/M.Tech/Project/M.T.P._Colab/full_TEM_image_1.jpg'
part1=cv2.imread(part1_path)

img_tensor = torch.from_numpy(part1).permute(2, 0, 1).float()  
resize_transform = transforms.Resize((256, 256))

img_resized = resize_transform(img_tensor)

logits_mask = model(img_resized.to(DEVICE).unsqueeze(0))
pred_mask = torch.sigmoid(logits_mask)
pred_mask = (pred_mask>0.5)*1.0

test_show(img_resized,pred_mask.detach().cpu().squeeze(0))

I have got very bad segmentation result

For Image size 256*256 Result enter image description here

For Image size 1004*994 Result enter image description here

I have tried to crop the bigger dimension image into 8 parts, then the model segment the image accurately but it not what I want what should I do?

$\endgroup$
4
  • $\begingroup$ In the training data, were the objects all the same size? Were they sized more similar to the top image? A trained UNet will be sensitive to object sizes if it only observes objects of similar scales during training. $\endgroup$
    – bogovicj
    Commented Apr 12 at 15:45
  • $\begingroup$ Yes, while training all the data are of 256*256 size. But Now I want to apply on the size of 1002*994 pixel, but while reducing the size from 1002*994, I'm losing the information from image and in the end I got that worst segmentation result $\endgroup$ Commented Apr 13 at 9:59
  • $\begingroup$ I'm not asking about how big the images are, but rather the size of the objects in the image. The circles at the top appear to be ~25 pixels in diameter, and the circles in the bottom image appear to be ~5 image in diameter. Did the training data contain circles that ere ~5 pixel wide? $\endgroup$
    – bogovicj
    Commented Apr 13 at 20:29
  • $\begingroup$ While training there are mixed kind of image circles some image are having ~25 pixels in diameter, also some image contains circle ~10 pixel in diameter roughly. $\endgroup$ Commented Apr 16 at 5:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.