Closed heikeyuhuajia closed 6 months ago
Hello, I checked other issues and found that it could be caused by incorrect generation of indice0 and indice1. Q1:I used your default mask.py, may I know how should I generate the corrected mask.py when I batchsize=32:
import numpy as np
import torch
import scipy.io as io
x = 64
b = np.array(np.identity(x ** 2), dtype='int8')
# b=np.identity(x**2)
#b=torch.eye(x**2)
for i in range(x**2):
if i == 0:
b[i][i+1]=1
b[i][i+x]=1
b[i][i+x+1]=1
continue
if i == x - 1:
b[i][i-1]=1
b[i][i+x]=1
b[i][i+x-1]=1
continue
if i == x**2 - x:
b[i][i+1]=1
b[i][i-x]=1
b[i][i-x+1]=1
continue
if i == x**2 - 1:
b[i][i-1]=1
b[i][i-x]=1
b[i][i-x-1]=1
continue
if 0 < i < x - 1:
b[i][i-1]=1
b[i][i+1]=1
b[i][i+x]=1
b[i][i+x-1]=1
b[i][i+x+1]=1
continue
if x**2-x < i < x**2 - 1:
b[i][i-1]=1
b[i][i+1]=1
b[i][i-x]=1
b[i][i-x-1]=1
b[i][i-x+1]=1
continue
if i%x==0:
b[i][i+1]=1
b[i][i+1+x]=1
b[i][i+1-x]=1
b[i][i+x]=1
b[i][i-x]=1
continue
if i%x==x-1:
b[i][i-1]=1
b[i][i-1+x]=1
b[i][i-1-x]=1
b[i][i+x]=1
b[i][i-x]=1
continue
else:
b[i][i-1]=1
b[i][i+1]=1
b[i][i-x]=1
b[i][i+x]=1
b[i][i-x+1]=1
b[i][i-x-1]=1
b[i][i+x-1]=1
b[i][i+x+1]=1
#indice0
length = len(b)
for i in range(3):
leftmaxtric = np.row_stack((b, np.array(np.zeros((length, length)),dtype='int8')))
rightmaxtric = np.row_stack((np.array(np.zeros((length, length)),dtype='int8'), b))
b = np.hstack((leftmaxtric, rightmaxtric))
length=length*2
b = torch.tensor(b)
print(b.shape)
indice = b.nonzero().t()
indice = indice.numpy()
print(indice.shape)
np.savetxt('indice0.txt', indice)
# indice1
for i in range(3):
a = b
b = np.vstack((a, b))
b = torch.tensor(b)
print(b.shape)
indice = b.nonzero().t()
indice = indice.numpy()
print(indice.shape)
np.savetxt('indice1.txt', indice)
Q2: Since I want to compare my paper with yours, I need to use the settings in your paper for comparison, do I still need to make any changes when I load your checkpoints? Previously I was using your default commands for testing:
gpus=0
data_name=LEVIR
net_G=Reliable_transformer
split=test
project_name=BestLEVIR
checkpoint_name=best_ckpt.pt
python eval_cd.py --split ${split} --net_G ${net_G} --checkpoint_name ${checkpoint_name} --gpu_ids ${gpus} --project_name ${project_name} --data_name ${data_name}
print(indice.shape)
Thank you very much for your interest in this work. A1: If batchsize is 8, index 0 is spliced by 8 identical masks along the main diagonal, and index 1 is spliced horizontally, which can be viewed by print(indice.shape). If batchsize is changed to 32, it is spliced by 32 identical masks. A2: The initialization of Kmeans is fixed here in order to make the experimental results deterministic, and you can try using a different class-centered initialization. No other hyperparameters need to be changed.
Thank you very much for your reply, it has been resolved with your help, good luck with your work.
Thank you for your work. But when I execute the test file as per the script you have given, I get the following problem, my dataset is also of 256*256 size and no other part of the network has been modified.