Skip to content

np.bool -> bool #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def eval_cosine_scoring(
vad = v_reader.read([key.seg_set[j]])[0]
tot_frames = len(vad)
speech_frames = np.sum(vad)
vad = torch.as_tensor(vad.astype(np.bool, copy=False), dtype=torch.bool).to(
vad = torch.as_tensor(vad.astype(bool, copy=False), dtype=torch.bool).to(
device
)
model.vad_t = vad
Expand Down Expand Up @@ -361,9 +361,7 @@ def main():

parser.add_argument("--vad", dest="vad_spec", default=None)
parser.add_argument(
"--vad-path-prefix",
default=None,
help=("scp file_path prefix for vad"),
"--vad-path-prefix", default=None, help=("scp file_path prefix for vad"),
)

parser.add_argument("--model-path", required=True)
Expand Down
13 changes: 3 additions & 10 deletions hyperion/bin/generate_adv_attacks_xvector_classif.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,13 @@ def generate_attacks(
vad = v_reader.read([key])[0]
tot_frames = len(vad)
speech_frames = np.sum(vad)
vad = torch.as_tensor(vad.astype(np.bool, copy=False), dtype=torch.bool).to(
vad = torch.as_tensor(vad.astype(bool, copy=False), dtype=torch.bool).to(
device
)
model.vad = vad
logging.info(
"utt %s detected %d/%d (%.2f %%) speech frames"
% (
key,
speech_frames,
tot_frames,
speech_frames / tot_frames * 100,
)
% (key, speech_frames, tot_frames, speech_frames / tot_frames * 100,)
)

t2 = time.time()
Expand Down Expand Up @@ -329,9 +324,7 @@ def main():

parser.add_argument("--vad", dest="vad_spec", default=None)
parser.add_argument(
"--vad-path-prefix",
default=None,
help=("scp file_path prefix for vad"),
"--vad-path-prefix", default=None, help=("scp file_path prefix for vad"),
)

parser.add_argument("--model-path", required=True)
Expand Down
2 changes: 1 addition & 1 deletion hyperion/bin/generate_adv_attacks_xvector_verif.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def generate_attacks(
vad = v_reader.read([key.seg_set[j]])[0]
tot_frames = len(vad)
speech_frames = np.sum(vad)
vad = torch.as_tensor(vad.astype(np.bool, copy=False), dtype=torch.bool).to(
vad = torch.as_tensor(vad.astype(bool, copy=False), dtype=torch.bool).to(
device
)
model.vad_t = vad
Expand Down
2 changes: 1 addition & 1 deletion hyperion/np/classifiers/greedy_fusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def fit(self, x, class_ids, sample_weights=None):
num_cands = len(cand_systems)
cand_min_dcf = np.zeros((num_cands,), dtype=float_cpu())
cand_act_dcf = np.zeros((num_cands,), dtype=float_cpu())
all_pos = np.zeros((num_cands,), dtype=np.bool)
all_pos = np.zeros((num_cands,), dtype=bool)
cand_weights = []
for j in range(num_cands):
system_idx_ij = np.concatenate(
Expand Down
4 changes: 2 additions & 2 deletions hyperion/np/diarization/diar_ahc_plda.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _plot_score_hist(scores, output_file, thr=None, gmm=None):
output_dir = Path(output_file).parent
output_dir.mkdir(parents=True, exist_ok=True)

mask = np.triu(np.ones(scores.shape, dtype=np.bool), 1)
mask = np.triu(np.ones(scores.shape, dtype=bool), 1)
scores_r = scores[mask].ravel()

_, bins, _ = plt.hist(
Expand Down Expand Up @@ -96,7 +96,7 @@ def _plot_score_hist(scores, output_file, thr=None, gmm=None):
@staticmethod
def _unsup_gmm_calibration(scores):
"""Performs unsupervised calibration on the scores by training a GMM."""
mask = np.triu(np.ones(scores.shape, dtype=np.bool), 1)
mask = np.triu(np.ones(scores.shape, dtype=bool), 1)
scores_r = scores[mask].ravel()[:, None] # N x 1
gmm_1c = GMM(num_comp=1)
gmm_1c.fit(scores_r, epochs=1)
Expand Down
2 changes: 1 addition & 1 deletion hyperion/np/pdfs/jfa/jfa_total.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def TT(self):
def _upptr(self):
"""Upper triangular mask."""
if self.__upptr is None:
self.__upptr = np.triu(np.ones(self.y_dim, dtype=np.bool))
self.__upptr = np.triu(np.ones(self.y_dim, dtype=bool))
return self.__upptr

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion hyperion/utils/info_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def get_loc(self, keys):
if isinstance(loc, int):
return loc

if isinstance(loc, np.ndarray) and loc.dtype == np.bool:
if isinstance(loc, np.ndarray) and loc.dtype == bool:
return np.nonzero(loc)[0]

return list(range(loc.start, loc.stop, loc.step))
Expand Down
2 changes: 1 addition & 1 deletion hyperion/utils/rttm.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ def get_bin_sample_mask_for_spk(

tend[tend > max_samples] = max_samples

vad = np.zeros((max_samples,), dtype=np.bool)
vad = np.zeros((max_samples,), dtype=bool)
for i, j in zip(tbeg, tend):
if j > i:
vad[i:j] = True
Expand Down
4 changes: 2 additions & 2 deletions hyperion/utils/vad_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def vad_timestamps_to_bin(
if max_frames is not None and num_frames < max_frames:
num_frames = max_frames

vad = np.zeros((num_frames,), dtype=np.bool)
vad = np.zeros((num_frames,), dtype=bool)
frame_start = np.ceil(
(in_timestamps[:, 0] - (pad + frame_center)) / frame_shift
).astype(dtype=np.int)
Expand Down Expand Up @@ -242,7 +242,7 @@ def intersect_segment_timestamps_with_vad(in_timestamps, vad_timestamps):
vad_start = vad_timestamps[:, 0]
vad_end = vad_timestamps[:, 1]
num_vad_segs = len(vad_start)
speech_idx = np.zeros((in_timestamps.shape[0],), dtype=np.bool)
speech_idx = np.zeros((in_timestamps.shape[0],), dtype=bool)
out_timestamps = []
out_timestamps2speech_segs = []
count_speech = 0
Expand Down