Skip to content
Open
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
4 changes: 2 additions & 2 deletions beit/dall_e/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion beit/masking_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion beit/semantic_segmentation/mmcv_custom/resize_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion beit2/masking_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions beit3/randaug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand All @@ -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
Expand Down