here is the code:
import torch
import torch.nn as nn
import torch.nn.functional as F
import cv2
import numpy as np
import matplotlib.pyplot as plt
IMG_SIZE = 100
image = cv2.imread(“C:\Users\Dutchfoundation\Desktop\AI\Torch\image_01.jpg”,cv2.IMREAD_GRAYSCALE)
template = cv2.imread(“C:\Users\Dutchfoundation\Desktop\AI\Torch\template_01.jpg”,cv2.IMREAD_GRAYSCALE)
image = cv2.resize(image, (IMG_SIZE, IMG_SIZE))
template = cv2.resize(template, (IMG_SIZE, IMG_SIZE))
print(“Image:”,image.shape)
print(“Template:”,template.shape)
image_tensor = torch.Tensor(image).view(-1,100,100)
template_tensor = torch.Tensor(template).view(-1,100,100)
print(“Tensor Image:”,image_tensor.shape)
print(“Tensor Template:”,template_tensor.shape)
image_final = image_tensor.view(-1,1,100,100)
template_final = template_tensor.view(-1,1,100,100)
print(“Final Image:”,image_final.shape)
print(“Final Template:”,template_final.shape)
corr_map = F.conv2d(image_final, template_final)
print(corr_map.shape)
#plt.imshow(corr_map)
The output shape of the corr_map is [1,1,1,1] which does’nt make sense