categories = ['background', 'Car', 'Truck', 'Pedestrian']
one_hot_category = np.eye(len(categories))
one_hot_category
# array([[ 1., 0., 0., 0.],
# [ 0., 1., 0., 0.],
# [ 0., 0., 1., 0.],
# [ 0., 0., 0., 1.]])