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 Resultenter image description here

For Image size 1004*994 Resultenter 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
    CommentedApr 12, 2024 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$CommentedApr 13, 2024 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
    CommentedApr 13, 2024 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$CommentedApr 16, 2024 at 5:49

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.