Skip to content
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

fix error in Issue https://github.com/j96w/DenseFusion/issues/127 #145

Open
wants to merge 2 commits into
base: Pytorch-1.0
Choose a base branch
from
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
16 changes: 8 additions & 8 deletions datasets/linemod/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ def __init__(self, mode, num, add_noise, root, noise_trans, refine):
self.list_label.append('{0}/segnet_results/{1}_label/{2}_label.png'.format(self.root, '%02d' % item, input_line))
else:
self.list_label.append('{0}/data/{1}/mask/{2}.png'.format(self.root, '%02d' % item, input_line))

self.list_obj.append(item)
self.list_rank.append(int(input_line))

meta_file = open('{0}/data/{1}/gt.yml'.format(self.root, '%02d' % item), 'r')
self.meta[item] = yaml.load(meta_file)
self.pt[item] = ply_vtx('{0}/models/obj_{1}.ply'.format(self.root, '%02d' % item))

print("Object {0} buffer loaded".format(item))

self.length = len(self.list_rgb)
Expand All @@ -77,7 +77,7 @@ def __init__(self, mode, num, add_noise, root, noise_trans, refine):

self.xmap = np.array([[j for i in range(640)] for j in range(480)])
self.ymap = np.array([[i for i in range(640)] for j in range(480)])

self.num = num
self.add_noise = add_noise
self.trancolor = transforms.ColorJitter(0.2, 0.2, 0.2, 0.05)
Expand All @@ -93,7 +93,7 @@ def __getitem__(self, index):
depth = np.array(Image.open(self.list_depth[index]))
label = np.array(Image.open(self.list_label[index]))
obj = self.list_obj[index]
rank = self.list_rank[index]
rank = self.list_rank[index]

if obj == 2:
for i in range(0, len(self.meta[obj][rank])):
Expand All @@ -108,7 +108,7 @@ def __getitem__(self, index):
mask_label = ma.getmaskarray(ma.masked_equal(label, np.array(255)))
else:
mask_label = ma.getmaskarray(ma.masked_equal(label, np.array([255, 255, 255])))[:, :, 0]

mask = mask_label * mask_depth

if self.add_noise:
Expand Down Expand Up @@ -143,7 +143,7 @@ def __getitem__(self, index):
choose = choose[c_mask.nonzero()]
else:
choose = np.pad(choose, (0, self.num - len(choose)), 'wrap')

depth_masked = depth[rmin:rmax, cmin:cmax].flatten()[choose][:, np.newaxis].astype(np.float32)
xmap_masked = self.xmap[rmin:rmax, cmin:cmax].flatten()[choose][:, np.newaxis].astype(np.float32)
ymap_masked = self.ymap[rmin:rmax, cmin:cmax].flatten()[choose][:, np.newaxis].astype(np.float32)
Expand Down Expand Up @@ -215,7 +215,7 @@ def get_num_points_mesh(self):

def mask_to_bbox(mask):
mask = mask.astype(np.uint8)
_, contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
x = 0
y = 0
w = 0
Expand All @@ -239,7 +239,7 @@ def get_bbox(bbox):
if bbx[2] < 0:
bbx[2] = 0
if bbx[3] >= 640:
bbx[3] = 639
bbx[3] = 639
rmin, rmax, cmin, cmax = bbx[0], bbx[1], bbx[2], bbx[3]
r_b = rmax - rmin
for tt in range(len(border_list)):
Expand Down
2 changes: 1 addition & 1 deletion lib/knn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import functools
import torch
from torch.autograd import Variable, Function
from lib.knn import knn_pytorch as knn_pytorch
from lib.knn.knn_pytorch import knn_pytorch

class KNearestNeighbor(Function):
""" Compute k nearest neighbors for each query point.
Expand Down