# SAM image size for fine-tuning

**URL:** <https://discuss.huggingface.co/t/sam-image-size-for-fine-tuning/39666>\
**Category:** Intermediate\
**Created:** [May 12, 2023, 3:01pm UTC](https://discuss.huggingface.co/t/sam-image-size-for-fine-tuning/39666 "2023-05-12T15:01:40Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [May 13, 2023, 9:17am UTC](https://discuss.huggingface.co/t/sam-image-size-for-fine-tuning/39666/2 "2023-05-13T09:17:58Z")

</div>

Hi,

Thanks for your interest in my notebook! You could use torch.nn.functional.interpolate to interpolate the predicted masks to the appropriate size before calculating the loss:

```auto
from torch import nn

predicted_masks = nn.functional.interpolate(predicted_masks,
                size=(1024, 1024),
                mode='bilinear',
                align_corners=False)

```

This is also used in the postprocessing method of `SamImageProcessor`.

---

_[View the full topic](https://discuss.huggingface.co/t/sam-image-size-for-fine-tuning/39666)._
