Lets assume you have loaded you model as ‘model’

Load you image to the kernel ( I recomment using PIL)

from PIL import Image
image = Image.open('path')


Perform image transforms

import torchvision.transforms as tf
toTensor = tf.Compose([
    tf.ToTensor()
])
image_input = toTensor(image)
image_input = image_input.resize(1,3,1500,1500)
image_input.shape


Predict

with torch.no_grad():
            preds = torch.sigmoid(model(image_input))
            preds = (preds > 0.19).float()


Plot the results

I’ve done similar stuff in a project maybe this might help
  

      github.com
  

  
    aryaman4152/Satellite-images-semantic-segmentation/blob/main/Prediction.ipynb 1


    {
 "cells": [
  {
   "cell_type": "markdown",
   "id": "7de940cc",
   "metadata": {},
   "source": [
    "# Load model and make predictions (find roads)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fb09a229",
   "metadata": {},
   "source": [
    "### Redefining model "
   ]
  },
  {
   "cell_type": "code",



  This file has been truncated. show original