MCPcopy Create free account
hub / github.com/OpenGVLab/UniFormerV2 / as_binary_vector

Function as_binary_vector

slowfast/datasets/utils.py:259–272  ·  view source on GitHub ↗

Construct binary label vector given a list of label indices. Args: labels (list): The input label list. num_classes (int): Number of classes of the label vector. Returns: labels (numpy array): the resulting binary vector.

(labels, num_classes)

Source from the content-addressed store, hash-verified

257
258
259def as_binary_vector(labels, num_classes):
260 """
261 Construct binary label vector given a list of label indices.
262 Args:
263 labels (list): The input label list.
264 num_classes (int): Number of classes of the label vector.
265 Returns:
266 labels (numpy array): the resulting binary vector.
267 """
268 label_arr = np.zeros((num_classes,))
269
270 for lbl in set(labels):
271 label_arr[lbl] = 1.0
272 return label_arr
273
274
275def aggregate_labels(label_list):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected