Skip to content

Commit 8d9fd3d

Browse files
committed
Add support for NumPy 1.24.* (pt. 3)
Some bundled upstream code looks unmaintained. This commit patches some of it.
1 parent 568fb4c commit 8d9fd3d

File tree

6 files changed

+43
-24
lines changed

6 files changed

+43
-24
lines changed

scripts/bundled_sources.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Since commit 110549b2 this extension bundles some code from other repositories.
2+
This was done to prevent possible upstream breakage and allow fixing breakage quicker.
3+
This file provides information about the original location of the code.
4+
*** Some of the bundled code was already modified. ***
5+
6+
dmidas
7+
https://github.com/isl-org/MiDaS/tree/master/midas/
8+
9+
dzoedepth
10+
https://github.com/isl-org/ZoeDepth/tree/main/zoedepth/
11+
12+
inpaint
13+
https://github.com/vt-vl-lab/3d-photo-inpainting/
14+
15+
lib
16+
https://github.com/aim-uofa/AdelaiDepth/tree/main/LeReS/Minist_Test/lib/
17+
18+
pix2pix
19+
https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/

scripts/dzoedepth/data/transforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def __call__(self, sample):
372372
if self.__use_mask:
373373
mask = sample["mask"]
374374
else:
375-
mask = np.ones_like(disp, dtype=np.bool)
375+
mask = np.ones_like(disp, dtype=bool)
376376

377377
if np.sum(mask) == 0:
378378
return sample

scripts/inpaint/mesh.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def reassign_floating_island(mesh, info_on_pix, image, depth):
271271
_, label_lost_map = cv2.connectedComponents(lost_map.astype(np.uint8), connectivity=4)
272272
mask = np.zeros((H, W))
273273
mask[bord_up:bord_down, bord_left:bord_right] = 1
274-
label_lost_map = (label_lost_map * mask).astype(np.int)
274+
label_lost_map = (label_lost_map * mask).astype(int)
275275

276276
for i in range(1, label_lost_map.max()+1):
277277
lost_xs, lost_ys = np.where(label_lost_map == i)
@@ -966,8 +966,8 @@ def context_and_holes(mesh, edge_ccs, config, specific_edge_id, specific_edge_lo
966966
mask_ccs = copy.deepcopy(edge_ccs)
967967
forbidden_len = 3
968968
forbidden_map = np.ones((mesh.graph['H'] - forbidden_len, mesh.graph['W'] - forbidden_len))
969-
forbidden_map = np.pad(forbidden_map, ((forbidden_len, forbidden_len), (forbidden_len, forbidden_len)), mode='constant').astype(np.bool)
970-
cur_tmp_mask_map = np.zeros_like(forbidden_map).astype(np.bool)
969+
forbidden_map = np.pad(forbidden_map, ((forbidden_len, forbidden_len), (forbidden_len, forbidden_len)), mode='constant').astype(bool)
970+
cur_tmp_mask_map = np.zeros_like(forbidden_map).astype(bool)
971971
#passive_background = 10 if 10 is not None else background_thickness
972972
#passive_context = 1 if 1 is not None else context_thickness
973973
passive_background = 10 #if 10 is not None else background_thickness
@@ -988,7 +988,7 @@ def context_and_holes(mesh, edge_ccs, config, specific_edge_id, specific_edge_lo
988988
tmp_mask_nodes = copy.deepcopy(mask_ccs[edge_id])
989989
tmp_intersect_nodes = []
990990
tmp_intersect_context_nodes = []
991-
mask_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=np.bool)
991+
mask_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=bool)
992992
context_depth = np.zeros((mesh.graph['H'], mesh.graph['W']))
993993
comp_cnt_depth = np.zeros((mesh.graph['H'], mesh.graph['W']))
994994
connect_map = np.zeros((mesh.graph['H'], mesh.graph['W']))
@@ -1015,7 +1015,7 @@ def context_and_holes(mesh, edge_ccs, config, specific_edge_id, specific_edge_lo
10151015
connect_map[xx[0], xx[1]] = xx[2]
10161016
tmp_context_nodes = [*context_ccs[edge_id]]
10171017
tmp_erode.append([*context_ccs[edge_id]])
1018-
context_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=np.bool)
1018+
context_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=bool)
10191019
if (context_map.astype(np.uint8) * mask_map.astype(np.uint8)).max() > 0:
10201020
import pdb; pdb.set_trace()
10211021
for node in tmp_context_nodes:
@@ -1025,14 +1025,14 @@ def context_and_holes(mesh, edge_ccs, config, specific_edge_id, specific_edge_lo
10251025
if (context_map.astype(np.uint8) * mask_map.astype(np.uint8)).max() > 0:
10261026
import pdb; pdb.set_trace()
10271027
tmp_intouched_nodes = [*intouched_ccs[edge_id]]
1028-
intouched_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=np.bool)
1028+
intouched_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=bool)
10291029
for node in tmp_intouched_nodes: intouched_map[node[0], node[1]] = True
10301030
intouched_map[mask_map == True] = False
10311031
tmp_redundant_nodes = set()
10321032
tmp_noncont_nodes = set()
1033-
noncont_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=np.bool)
1034-
intersect_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=np.bool)
1035-
intersect_context_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=np.bool)
1033+
noncont_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=bool)
1034+
intersect_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=bool)
1035+
intersect_context_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=bool)
10361036
if i > passive_background and inpaint_iter == 0:
10371037
new_tmp_intersect_nodes = None
10381038
new_tmp_intersect_nodes = []
@@ -1311,9 +1311,9 @@ def context_and_holes(mesh, edge_ccs, config, specific_edge_id, specific_edge_lo
13111311
tmp_context_nodes = copy.deepcopy(ecnt_cc)
13121312
tmp_invalid_context_nodes = copy.deepcopy(invalid_extend_edge_ccs[ecnt_id])
13131313
tmp_mask_nodes = copy.deepcopy(accomp_extend_context_ccs[ecnt_id])
1314-
tmp_context_map = np.zeros((mesh.graph['H'], mesh.graph['W'])).astype(np.bool)
1315-
tmp_mask_map = np.zeros((mesh.graph['H'], mesh.graph['W'])).astype(np.bool)
1316-
tmp_invalid_context_map = np.zeros((mesh.graph['H'], mesh.graph['W'])).astype(np.bool)
1314+
tmp_context_map = np.zeros((mesh.graph['H'], mesh.graph['W'])).astype(bool)
1315+
tmp_mask_map = np.zeros((mesh.graph['H'], mesh.graph['W'])).astype(bool)
1316+
tmp_invalid_context_map = np.zeros((mesh.graph['H'], mesh.graph['W'])).astype(bool)
13171317
for node in tmp_mask_nodes:
13181318
tmp_mask_map[node[0], node[1]] = True
13191319
for node in context_ccs[ecnt_id]:

scripts/inpaint/mesh_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,9 @@ def extrapolate(global_mesh,
405405
fpath_ids = fpath_ids[1:] if fpath_ids.shape[0] > 0 and fpath_ids[0] == -1 else []
406406
fpath_real_id_map = np.zeros_like(global_fpath_map) - 1
407407
for fpath_id in fpath_ids:
408-
fpath_real_id = np.unique(((global_fpath_map == fpath_id).astype(np.int) * (other_edge_with_id + 1)) - 1)
408+
fpath_real_id = np.unique(((global_fpath_map == fpath_id).astype(int) * (other_edge_with_id + 1)) - 1)
409409
fpath_real_id = fpath_real_id[1:] if fpath_real_id.shape[0] > 0 and fpath_real_id[0] == -1 else []
410-
fpath_real_id = fpath_real_id.astype(np.int)
410+
fpath_real_id = fpath_real_id.astype(int)
411411
fpath_real_id = np.bincount(fpath_real_id).argmax()
412412
fpath_real_id_map[global_fpath_map == fpath_id] = fpath_real_id
413413
nxs, nys = np.where((fpath_map > -1))

scripts/inpaint/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ def filter_irrelevant_edge_new(self_edge, comp_edge, other_edges, other_edges_wi
6969
self_edge = self_edge.squeeze()
7070
dilate_bevel_self_edge = cv2.dilate((self_edge + comp_edge).astype(np.uint8), np.array([[1,1,1],[1,1,1],[1,1,1]]), iterations=1)
7171
dilate_cross_self_edge = cv2.dilate((self_edge + comp_edge).astype(np.uint8), np.array([[0,1,0],[1,1,1],[0,1,0]]).astype(np.uint8), iterations=1)
72-
edge_ids = np.unique(other_edges_with_id * context + (-1) * (1 - context)).astype(np.int)
72+
edge_ids = np.unique(other_edges_with_id * context + (-1) * (1 - context)).astype(int)
7373
end_depth_maps = np.zeros_like(self_edge)
74-
self_edge_ids = np.sort(np.unique(other_edges_with_id[self_edge > 0]).astype(np.int))
74+
self_edge_ids = np.sort(np.unique(other_edges_with_id[self_edge > 0]).astype(int))
7575
self_edge_ids = self_edge_ids[1:] if self_edge_ids.shape[0] > 0 and self_edge_ids[0] == -1 else self_edge_ids
76-
self_comp_ids = np.sort(np.unique(other_edges_with_id[comp_edge > 0]).astype(np.int))
76+
self_comp_ids = np.sort(np.unique(other_edges_with_id[comp_edge > 0]).astype(int))
7777
self_comp_ids = self_comp_ids[1:] if self_comp_ids.shape[0] > 0 and self_comp_ids[0] == -1 else self_comp_ids
7878
edge_ids = edge_ids[1:] if edge_ids[0] == -1 else edge_ids
7979
other_edges_info = []
@@ -1067,8 +1067,8 @@ def refine_color_around_edge(mesh, info_on_pix, edge_ccs, config, spdb=False):
10671067
for edge_id, edge_cc in enumerate(edge_ccs):
10681068
if len(edge_cc) == 0:
10691069
continue
1070-
near_maps = np.zeros((H, W)).astype(np.bool)
1071-
far_maps = np.zeros((H, W)).astype(np.bool)
1070+
near_maps = np.zeros((H, W)).astype(bool)
1071+
far_maps = np.zeros((H, W)).astype(bool)
10721072
tmp_far_nodes = set()
10731073
far_nodes = set()
10741074
near_nodes = set()

scripts/lib/test_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ def reconstruct_3D(depth, f):
153153
y = (v - cv) * depth / f
154154
z = depth
155155

156-
x = np.reshape(x, (width * height, 1)).astype(np.float)
157-
y = np.reshape(y, (width * height, 1)).astype(np.float)
158-
z = np.reshape(z, (width * height, 1)).astype(np.float)
156+
x = np.reshape(x, (width * height, 1)).astype(float)
157+
y = np.reshape(y, (width * height, 1)).astype(float)
158+
z = np.reshape(z, (width * height, 1)).astype(float)
159159
pcd = np.concatenate((x, y, z), axis=1)
160-
pcd = pcd.astype(np.int)
160+
pcd = pcd.astype(int)
161161
return pcd
162162

163163
def save_point_cloud(pcd, rgb, filename, binary=True):

0 commit comments

Comments
 (0)