diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..32baf48 Binary files /dev/null and b/.DS_Store differ diff --git a/test.py b/test.py deleted file mode 100644 index b7579ad..0000000 --- a/test.py +++ /dev/null @@ -1,13 +0,0 @@ -from utils.one_hot_encoder import HotEncoder -import numpy as np -import torch -import skimage -from torch.nn.functional import one_hot -img__= skimage.io.imread("/Users/madhav/DataSets/data_semantics/training/semantic_rgb/000035_10.tif") -encoder= HotEncoder(dir= '/Users/madhav/DataSets/data_semantics/training/semantic_rgb', extension="tif", is_binary= False, n_classes= 30) -color_dict= encoder.gen_colors() -onehottt= encoder.PerPixelClassMatrix(img__) -encoded= encoder.HotEncode(onehottt) -ch= encoder.channelSplit(encoded) -for _ in range(30): - skimage.io.imsave(arr= ch[_].reshape(375,1242), fname= str(_)+".jpeg") diff --git a/utils/one_hot_encoder.py b/utils/one_hot_encoder.py index 323b438..b70416e 100644 --- a/utils/one_hot_encoder.py +++ b/utils/one_hot_encoder.py @@ -51,6 +51,8 @@ def PerPixelClassMatrix(self, Image): class_map[x][y]= self.color[clr] return class_map def HotEncode(self, class_map): + """Inputs the class map of the image and returns the hot encoded + N channel output. Each channel represents the presence of a class per pixel""" assert isinstance(class_map, np.ndarray), "Class map has to be an ndarray and not {}".format(type(class_map)) shape_= class_map.shape encoded= np.zeros(shape= (shape_[0], shape_[1], self.n_classes), dtype=float)