October 2018
Intermediate to advanced
472 pages
10h 57m
English
With the make_normalize() function defined, let's now define a make_target function. This function accepts the segmentation array of shape (360,480) and then returns a segmentation target of shape (360,480,2). In the target, channel 0 represents the background and will have 1 in locations that represent the background in the image and zero elsewhere. Channel 1 represents the person and will have 1 in locations that represent the person in the image and 0 elsewhere. The following code implements the function:
def make_target(labels): """Function to one hot encode targets.""" x = np.zeros([360,480,2]) for i in range(360): for j in range(480): x[i,j,labels[i][j]]=1 return xplt.figure(figsize = (14,5))plt.subplot(1,2,1)plt.imshow(make_target(lab_lst[0])[:,:,0]) ...
Read now
Unlock full access