Skip to content

Add support for NumPy 1.24.* (pt. 3) #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2023
Merged
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
19 changes: 19 additions & 0 deletions scripts/bundled_sources.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Since commit 110549b2 this extension bundles some code from other repositories.
This was done to prevent possible upstream breakage and allow fixing breakage quicker.
This file provides information about the original location of the code.
*** Some of the bundled code was already modified. ***

dmidas
https://github.com/isl-org/MiDaS/tree/master/midas/

dzoedepth
https://github.com/isl-org/ZoeDepth/tree/main/zoedepth/

inpaint
https://github.com/vt-vl-lab/3d-photo-inpainting/

lib
https://github.com/aim-uofa/AdelaiDepth/tree/main/LeReS/Minist_Test/lib/

pix2pix
https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/
2 changes: 1 addition & 1 deletion scripts/dzoedepth/data/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def __call__(self, sample):
if self.__use_mask:
mask = sample["mask"]
else:
mask = np.ones_like(disp, dtype=np.bool)
mask = np.ones_like(disp, dtype=bool)

if np.sum(mask) == 0:
return sample
Expand Down
24 changes: 12 additions & 12 deletions scripts/inpaint/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def reassign_floating_island(mesh, info_on_pix, image, depth):
_, label_lost_map = cv2.connectedComponents(lost_map.astype(np.uint8), connectivity=4)
mask = np.zeros((H, W))
mask[bord_up:bord_down, bord_left:bord_right] = 1
label_lost_map = (label_lost_map * mask).astype(np.int)
label_lost_map = (label_lost_map * mask).astype(int)

for i in range(1, label_lost_map.max()+1):
lost_xs, lost_ys = np.where(label_lost_map == i)
Expand Down Expand Up @@ -966,8 +966,8 @@ def context_and_holes(mesh, edge_ccs, config, specific_edge_id, specific_edge_lo
mask_ccs = copy.deepcopy(edge_ccs)
forbidden_len = 3
forbidden_map = np.ones((mesh.graph['H'] - forbidden_len, mesh.graph['W'] - forbidden_len))
forbidden_map = np.pad(forbidden_map, ((forbidden_len, forbidden_len), (forbidden_len, forbidden_len)), mode='constant').astype(np.bool)
cur_tmp_mask_map = np.zeros_like(forbidden_map).astype(np.bool)
forbidden_map = np.pad(forbidden_map, ((forbidden_len, forbidden_len), (forbidden_len, forbidden_len)), mode='constant').astype(bool)
cur_tmp_mask_map = np.zeros_like(forbidden_map).astype(bool)
#passive_background = 10 if 10 is not None else background_thickness
#passive_context = 1 if 1 is not None else context_thickness
passive_background = 10 #if 10 is not None else background_thickness
Expand All @@ -988,7 +988,7 @@ def context_and_holes(mesh, edge_ccs, config, specific_edge_id, specific_edge_lo
tmp_mask_nodes = copy.deepcopy(mask_ccs[edge_id])
tmp_intersect_nodes = []
tmp_intersect_context_nodes = []
mask_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=np.bool)
mask_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=bool)
context_depth = np.zeros((mesh.graph['H'], mesh.graph['W']))
comp_cnt_depth = np.zeros((mesh.graph['H'], mesh.graph['W']))
connect_map = np.zeros((mesh.graph['H'], mesh.graph['W']))
Expand All @@ -1015,7 +1015,7 @@ def context_and_holes(mesh, edge_ccs, config, specific_edge_id, specific_edge_lo
connect_map[xx[0], xx[1]] = xx[2]
tmp_context_nodes = [*context_ccs[edge_id]]
tmp_erode.append([*context_ccs[edge_id]])
context_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=np.bool)
context_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=bool)
if (context_map.astype(np.uint8) * mask_map.astype(np.uint8)).max() > 0:
import pdb; pdb.set_trace()
for node in tmp_context_nodes:
Expand All @@ -1025,14 +1025,14 @@ def context_and_holes(mesh, edge_ccs, config, specific_edge_id, specific_edge_lo
if (context_map.astype(np.uint8) * mask_map.astype(np.uint8)).max() > 0:
import pdb; pdb.set_trace()
tmp_intouched_nodes = [*intouched_ccs[edge_id]]
intouched_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=np.bool)
intouched_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=bool)
for node in tmp_intouched_nodes: intouched_map[node[0], node[1]] = True
intouched_map[mask_map == True] = False
tmp_redundant_nodes = set()
tmp_noncont_nodes = set()
noncont_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=np.bool)
intersect_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=np.bool)
intersect_context_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=np.bool)
noncont_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=bool)
intersect_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=bool)
intersect_context_map = np.zeros((mesh.graph['H'], mesh.graph['W']), dtype=bool)
if i > passive_background and inpaint_iter == 0:
new_tmp_intersect_nodes = None
new_tmp_intersect_nodes = []
Expand Down Expand Up @@ -1311,9 +1311,9 @@ def context_and_holes(mesh, edge_ccs, config, specific_edge_id, specific_edge_lo
tmp_context_nodes = copy.deepcopy(ecnt_cc)
tmp_invalid_context_nodes = copy.deepcopy(invalid_extend_edge_ccs[ecnt_id])
tmp_mask_nodes = copy.deepcopy(accomp_extend_context_ccs[ecnt_id])
tmp_context_map = np.zeros((mesh.graph['H'], mesh.graph['W'])).astype(np.bool)
tmp_mask_map = np.zeros((mesh.graph['H'], mesh.graph['W'])).astype(np.bool)
tmp_invalid_context_map = np.zeros((mesh.graph['H'], mesh.graph['W'])).astype(np.bool)
tmp_context_map = np.zeros((mesh.graph['H'], mesh.graph['W'])).astype(bool)
tmp_mask_map = np.zeros((mesh.graph['H'], mesh.graph['W'])).astype(bool)
tmp_invalid_context_map = np.zeros((mesh.graph['H'], mesh.graph['W'])).astype(bool)
for node in tmp_mask_nodes:
tmp_mask_map[node[0], node[1]] = True
for node in context_ccs[ecnt_id]:
Expand Down
4 changes: 2 additions & 2 deletions scripts/inpaint/mesh_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@ def extrapolate(global_mesh,
fpath_ids = fpath_ids[1:] if fpath_ids.shape[0] > 0 and fpath_ids[0] == -1 else []
fpath_real_id_map = np.zeros_like(global_fpath_map) - 1
for fpath_id in fpath_ids:
fpath_real_id = np.unique(((global_fpath_map == fpath_id).astype(np.int) * (other_edge_with_id + 1)) - 1)
fpath_real_id = np.unique(((global_fpath_map == fpath_id).astype(int) * (other_edge_with_id + 1)) - 1)
fpath_real_id = fpath_real_id[1:] if fpath_real_id.shape[0] > 0 and fpath_real_id[0] == -1 else []
fpath_real_id = fpath_real_id.astype(np.int)
fpath_real_id = fpath_real_id.astype(int)
fpath_real_id = np.bincount(fpath_real_id).argmax()
fpath_real_id_map[global_fpath_map == fpath_id] = fpath_real_id
nxs, nys = np.where((fpath_map > -1))
Expand Down
10 changes: 5 additions & 5 deletions scripts/inpaint/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ def filter_irrelevant_edge_new(self_edge, comp_edge, other_edges, other_edges_wi
self_edge = self_edge.squeeze()
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)
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)
edge_ids = np.unique(other_edges_with_id * context + (-1) * (1 - context)).astype(np.int)
edge_ids = np.unique(other_edges_with_id * context + (-1) * (1 - context)).astype(int)
end_depth_maps = np.zeros_like(self_edge)
self_edge_ids = np.sort(np.unique(other_edges_with_id[self_edge > 0]).astype(np.int))
self_edge_ids = np.sort(np.unique(other_edges_with_id[self_edge > 0]).astype(int))
self_edge_ids = self_edge_ids[1:] if self_edge_ids.shape[0] > 0 and self_edge_ids[0] == -1 else self_edge_ids
self_comp_ids = np.sort(np.unique(other_edges_with_id[comp_edge > 0]).astype(np.int))
self_comp_ids = np.sort(np.unique(other_edges_with_id[comp_edge > 0]).astype(int))
self_comp_ids = self_comp_ids[1:] if self_comp_ids.shape[0] > 0 and self_comp_ids[0] == -1 else self_comp_ids
edge_ids = edge_ids[1:] if edge_ids[0] == -1 else edge_ids
other_edges_info = []
Expand Down Expand Up @@ -1067,8 +1067,8 @@ def refine_color_around_edge(mesh, info_on_pix, edge_ccs, config, spdb=False):
for edge_id, edge_cc in enumerate(edge_ccs):
if len(edge_cc) == 0:
continue
near_maps = np.zeros((H, W)).astype(np.bool)
far_maps = np.zeros((H, W)).astype(np.bool)
near_maps = np.zeros((H, W)).astype(bool)
far_maps = np.zeros((H, W)).astype(bool)
tmp_far_nodes = set()
far_nodes = set()
near_nodes = set()
Expand Down
8 changes: 4 additions & 4 deletions scripts/lib/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ def reconstruct_3D(depth, f):
y = (v - cv) * depth / f
z = depth

x = np.reshape(x, (width * height, 1)).astype(np.float)
y = np.reshape(y, (width * height, 1)).astype(np.float)
z = np.reshape(z, (width * height, 1)).astype(np.float)
x = np.reshape(x, (width * height, 1)).astype(float)
y = np.reshape(y, (width * height, 1)).astype(float)
z = np.reshape(z, (width * height, 1)).astype(float)
pcd = np.concatenate((x, y, z), axis=1)
pcd = pcd.astype(np.int)
pcd = pcd.astype(int)
return pcd

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