diff --git a/CLIP-ViP/src/utils/basic_utils.py b/CLIP-ViP/src/utils/basic_utils.py index 3cd77fd..0c08638 100644 --- a/CLIP-ViP/src/utils/basic_utils.py +++ b/CLIP-ViP/src/utils/basic_utils.py @@ -155,9 +155,7 @@ def dissect_by_lengths(np_array, lengths, dim=0, assert_equal=True): np_array.shape[0] == sum(lengths), Output is a list of nd arrays, singlton dimention is kept""" if assert_equal: assert len(np_array) == sum(lengths) - length_indices = [0, ] - for i in range(len(lengths)): - length_indices.append(length_indices[i] + lengths[i]) + length_indices = [0, ] + np.add(length_indices,lengths).tolist() if dim == 0: array_list = [np_array[length_indices[i]:length_indices[i+1]] for i in range(len(lengths))] elif dim == 1: diff --git a/hd-vila/src/utils/basic_utils.py b/hd-vila/src/utils/basic_utils.py index 7fab2fc..7679ae0 100644 --- a/hd-vila/src/utils/basic_utils.py +++ b/hd-vila/src/utils/basic_utils.py @@ -155,9 +155,7 @@ def dissect_by_lengths(np_array, lengths, dim=0, assert_equal=True): np_array.shape[0] == sum(lengths), Output is a list of nd arrays, singlton dimention is kept""" if assert_equal: assert len(np_array) == sum(lengths) - length_indices = [0, ] - for i in range(len(lengths)): - length_indices.append(length_indices[i] + lengths[i]) + length_indices = [0, ] + np.add(length_indices,lengths).tolist() if dim == 0: array_list = [np_array[length_indices[i]:length_indices[i+1]] for i in range(len(lengths))] elif dim == 1: