I want to use SPADE to do image synthesis. My input is a bunch of .tif files, which I need to convert to jpeg. I wrote the following script :
for img in img_files:
tempstrg = img.split("_")
lab = [fl for fl in label_files if (tempstrg[1] in fl and tempstrg[2] in fl)]
image = Image.open(path_image + img)
label = Image.open(path_label + lab[0])
image = transforms.ToTensor()(image)
label = transforms.ToTensor()(label)
print(“uniques in image :”, len(np.unique(np.array(image))))
print(“uniques in label :”, len(np.unique(np.array(label))))
utils.save_image(image, img_jpg + str(index) + “.jpg”)
utils.save_image(label, label_jpg + str(index) + “.jpg”)
index = index + 1
expectedly, the label map has a very low number of unique values (6 in my case), so all is well. But when I do
for f in files:
label = Image.open(path + f)
label = transforms.ToTensor()(label)
print(label.size())
label = np.array(label)
print(len(np.unique(label)))
the number of label doesn’t stay the same, and SPADE training crashes because of it. Is there some sort of normalization / interpolation done somewhere that I’m not aware of ?