diff --git a/beit/dall_e/__init__.py b/beit/dall_e/__init__.py index cd982fa0c..3ddffde12 100644 --- a/beit/dall_e/__init__.py +++ b/beit/dall_e/__init__.py @@ -12,7 +12,7 @@ def load_model(path: str, device: torch.device = None) -> nn.Module: resp.raise_for_status() with io.BytesIO(resp.content) as buf: - return torch.load(buf, map_location=device) + return torch.load(buf, map_location=device, weights_only=False) else: with open(path, 'rb') as f: - return torch.load(f, map_location=device) + return torch.load(f, map_location=device, weights_only=False) diff --git a/beit/masking_generator.py b/beit/masking_generator.py index 75a7b0c3c..03bebba24 100644 --- a/beit/masking_generator.py +++ b/beit/masking_generator.py @@ -77,7 +77,7 @@ def _mask(self, mask, max_mask_patches): return delta def __call__(self): - mask = np.zeros(shape=self.get_shape(), dtype=np.int) + mask = np.zeros(shape=self.get_shape(), dtype=int) mask_count = 0 while mask_count < self.num_masking_patches: max_mask_patches = self.num_masking_patches - mask_count diff --git a/beit/semantic_segmentation/mmcv_custom/resize_transform.py b/beit/semantic_segmentation/mmcv_custom/resize_transform.py index 8780873fa..a7a9aaee5 100644 --- a/beit/semantic_segmentation/mmcv_custom/resize_transform.py +++ b/beit/semantic_segmentation/mmcv_custom/resize_transform.py @@ -196,7 +196,7 @@ def _resize_img(self, results): img, w_scale, h_scale = mmcv.imresize( results['img'], results['scale'], return_scale=True) scale_factor = np.array([w_scale, h_scale, w_scale, h_scale], - dtype=np.float32) + dtype=float) results['img'] = img results['img_shape'] = img.shape results['pad_shape'] = img.shape # in case that there is no padding diff --git a/beit2/masking_generator.py b/beit2/masking_generator.py index aa72e3197..c24c08ae4 100644 --- a/beit2/masking_generator.py +++ b/beit2/masking_generator.py @@ -77,7 +77,7 @@ def _mask(self, mask, max_mask_patches): return delta def __call__(self): - mask = np.zeros(shape=self.get_shape(), dtype=np.int32) + mask = np.zeros(shape=self.get_shape(), dtype=int) mask_count = 0 while mask_count < self.num_masking_patches: max_mask_patches = self.num_masking_patches - mask_count diff --git a/beit2/semantic_segmentation/mmcv_custom/resize_transform.py b/beit2/semantic_segmentation/mmcv_custom/resize_transform.py index 8780873fa..a7a9aaee5 100644 --- a/beit2/semantic_segmentation/mmcv_custom/resize_transform.py +++ b/beit2/semantic_segmentation/mmcv_custom/resize_transform.py @@ -196,7 +196,7 @@ def _resize_img(self, results): img, w_scale, h_scale = mmcv.imresize( results['img'], results['scale'], return_scale=True) scale_factor = np.array([w_scale, h_scale, w_scale, h_scale], - dtype=np.float32) + dtype=float) results['img'] = img results['img_shape'] = img.shape results['pad_shape'] = img.shape # in case that there is no padding diff --git a/beit3/randaug.py b/beit3/randaug.py index 359e97d06..f46fdb138 100644 --- a/beit3/randaug.py +++ b/beit3/randaug.py @@ -123,7 +123,7 @@ def brightness_func(img, factor): ''' same output as PIL.ImageEnhance.Contrast ''' - table = (np.arange(256, dtype=np.float32) * factor).clip(0, 255).astype(np.uint8) + table = (np.arange(256, dtype=float) * factor).clip(0, 255).astype(np.uint8) out = table[img] return out @@ -133,7 +133,7 @@ def sharpness_func(img, factor): The differences the this result and PIL are all on the 4 boundaries, the center areas are same ''' - kernel = np.ones((3, 3), dtype=np.float32) + kernel = np.ones((3, 3), dtype=float) kernel[1][1] = 5 kernel /= 13 degenerate = cv2.filter2D(img, -1, kernel) @@ -142,8 +142,8 @@ def sharpness_func(img, factor): elif factor == 1.0: out = img else: - out = img.astype(np.float32) - degenerate = degenerate.astype(np.float32)[1:-1, 1:-1, :] + out = img.astype(float) + degenerate = degenerate.astype(float)[1:-1, 1:-1, :] out[1:-1, 1:-1, :] = degenerate + factor * (out[1:-1, 1:-1, :] - degenerate) out = out.astype(np.uint8) return out