Skip to content

Commit

Permalink
Merge pull request #1866 from lRomul/replace_deprecated_np_types
Browse files Browse the repository at this point in the history
Replace deprecated NumPy aliases of builtin types
  • Loading branch information
rwightman authored Jul 7, 2023
2 parents c241081 + 158bf12 commit 394e814
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions timm/data/mixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def __init__(self, mixup_alpha=1., cutmix_alpha=0., cutmix_minmax=None, prob=1.0

def _params_per_elem(self, batch_size):
lam = np.ones(batch_size, dtype=np.float32)
use_cutmix = np.zeros(batch_size, dtype=np.bool)
use_cutmix = np.zeros(batch_size, dtype=bool)
if self.mixup_enabled:
if self.mixup_alpha > 0. and self.cutmix_alpha > 0.:
use_cutmix = np.random.rand(batch_size) < self.switch_prob
Expand All @@ -131,7 +131,7 @@ def _params_per_elem(self, batch_size):
elif self.mixup_alpha > 0.:
lam_mix = np.random.beta(self.mixup_alpha, self.mixup_alpha, size=batch_size)
elif self.cutmix_alpha > 0.:
use_cutmix = np.ones(batch_size, dtype=np.bool)
use_cutmix = np.ones(batch_size, dtype=bool)
lam_mix = np.random.beta(self.cutmix_alpha, self.cutmix_alpha, size=batch_size)
else:
assert False, "One of mixup_alpha > 0., cutmix_alpha > 0., cutmix_minmax not None should be true."
Expand Down
4 changes: 2 additions & 2 deletions timm/models/volo.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ def rand_bbox(size, lam, scale=1):
W = size[1] // scale
H = size[2] // scale
cut_rat = np.sqrt(1. - lam)
cut_w = np.int(W * cut_rat)
cut_h = np.int(H * cut_rat)
cut_w = (W * cut_rat).astype(int)
cut_h = (H * cut_rat).astype(int)

# uniform
cx = np.random.randint(W)
Expand Down

0 comments on commit 394e814

Please sign in to comment.