You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You have done great job! But i am confused about some code.
`def data_loader(path, batch_size, imSize,
mean=[0.5,0.5,0.5], std=[0.5,0.5,0.5],
ignore_val=44, pos_val=255, neg_val=155, pos_class=[0,1], neg_class=[2]):
# pos_class and neg_class in the folder name for keras ImageDataGenerator input
# 0,1,2 are low, high, normal
def imerge(img_gen, mask_gen):
for (imgs, img_labels), (mask, mask_labels) in itertools.zip_longest(img_gen, mask_gen):
# compute weight to ignore particular pixels
# mask = np.expand_dims(mask[:,:,:,0], axis=3)
mask = mask[:,:,:,0]
weight = np.ones(mask.shape, np.float32)
weight[mask==ignore_val] = 0.5 # this is set by experience
# In mask, ignored pixel has value ignore_val.
# The weight of these pixel is set to zero, so they do not contribute to loss
# The returned mask is still binary.
# compute per sample
for c, mask_label in enumerate(mask_labels):
assert(mask_labels[c] == img_labels[c])
mask_pointer = mask[c]
if mask_label in pos_class:
assert(np.where(mask_pointer == neg_val)[0].size == 0)
mask_pointer[mask_pointer==pos_val] = 1
elif mask_label in neg_class:
assert(np.where(mask_pointer == pos_val)[0].size == 0)
mask_pointer[mask_pointer==neg_val] = 0
else:
print ('WARNING: mask beyond the expected class range')
mask_pointer /= 255.0
mask_pointer[mask_pointer==ignore_val] = 0
assert set(np.unique(mask)).issubset([0, 1])
# assert set(np.unique(weight)).issubset([0, 1])
# img, mask = preprocess(imgs, mean, std, mask)
yield imgs, mask, weight, img_labels
`
code above in segmentation/data_gen.py. what is the aim to calculate 'mask_pointer'? it seems that it is not returned finally?
And 'assert set(np.unique(mask)).issubset([0, 1])' is apparently cannot be satisfied since the pixels in mask only belong to [44 255 155].
The text was updated successfully, but these errors were encountered:
You have done great job! But i am confused about some code.
`def data_loader(path, batch_size, imSize,
mean=[0.5,0.5,0.5], std=[0.5,0.5,0.5],
ignore_val=44, pos_val=255, neg_val=155, pos_class=[0,1], neg_class=[2]):
# pos_class and neg_class in the folder name for keras ImageDataGenerator input
# 0,1,2 are low, high, normal
`
code above in segmentation/data_gen.py. what is the aim to calculate 'mask_pointer'? it seems that it is not returned finally?
And 'assert set(np.unique(mask)).issubset([0, 1])' is apparently cannot be satisfied since the pixels in mask only belong to [44 255 155].
The text was updated successfully, but these errors were encountered: