From 8e7b49759bc8f183be79ebe0302bd13f60f6bf6a Mon Sep 17 00:00:00 2001 From: Aleksey Morozov <36787333+amrzv@users.noreply.github.com> Date: Mon, 24 Nov 2025 22:44:24 +0100 Subject: [PATCH 1/3] np.int -> int --- beit/masking_generator.py | 2 +- beit2/masking_generator.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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 From 9903e411bd180abeabd09492242ad21fb7682529 Mon Sep 17 00:00:00 2001 From: Aleksey Morozov <36787333+amrzv@users.noreply.github.com> Date: Mon, 24 Nov 2025 22:44:42 +0100 Subject: [PATCH 2/3] np.float32 -> float --- .../semantic_segmentation/mmcv_custom/resize_transform.py | 2 +- .../semantic_segmentation/mmcv_custom/resize_transform.py | 2 +- beit3/randaug.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) 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/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 From 444f945157c0ec05e7f5bce56b913a77f08d54f7 Mon Sep 17 00:00:00 2001 From: Aleksey Morozov <36787333+amrzv@users.noreply.github.com> Date: Mon, 24 Nov 2025 23:06:34 +0100 Subject: [PATCH 3/3] Specify weights_only=False in torch.load --- beit/dall_e/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)