Skip to content

Commit f5cabcc

Browse files
committed
fix and close #7 #12
1 parent 53261e7 commit f5cabcc

File tree

8 files changed

+13
-6
lines changed

8 files changed

+13
-6
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ data
33
*.pyc
44
*.ipynb
55
shapenetcore_partanno_segmentation_benchmark_v0/
6+
*.so
7+
.idea*
8+
cls/
9+
seg/

datasets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def __init__(self, root, npoints = 2500, classification = False, class_choice =
6060
print(self.classes)
6161
self.num_seg_classes = 0
6262
if not self.classification:
63-
for i in range(len(self.datapath)/50):
63+
for i in range(len(self.datapath)//50):
6464
l = len(np.unique(np.loadtxt(self.datapath[i][-1]).astype(np.uint8)))
6565
if l > self.num_seg_classes:
6666
self.num_seg_classes = l

download.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
wget https://shapenet.cs.stanford.edu/ericyi/shapenetcore_partanno_segmentation_benchmark_v0.zip
22
unzip shapenetcore_partanno_segmentation_benchmark_v0.zip
3+
rm shapenetcore_partanno_segmentation_benchmark_v0.zip

pointnet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def forward(self, x):
105105
x = F.relu(self.bn1(self.fc1(x)))
106106
x = F.relu(self.bn2(self.fc2(x)))
107107
x = self.fc3(x)
108-
return F.log_softmax(x), trans
108+
return F.log_softmax(x, dim=-1), trans
109109

110110
class PointNetDenseCls(nn.Module):
111111
def __init__(self, num_points = 2500, k = 2):
@@ -129,7 +129,7 @@ def forward(self, x):
129129
x = F.relu(self.bn3(self.conv3(x)))
130130
x = self.conv4(x)
131131
x = x.transpose(2,1).contiguous()
132-
x = F.log_softmax(x.view(-1,self.k))
132+
x = F.log_softmax(x.view(-1,self.k), dim=-1)
133133
x = x.view(batchsize, self.num_points, self.k)
134134
return x, trans
135135

show_cls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
points, target = points.cuda(), target.cuda()
4747
pred, _ = classifier(points)
4848
loss = F.nll_loss(pred, target)
49+
from IPython import embed; embed()
4950
pred_choice = pred.data.max(1)[1]
5051
correct = pred_choice.eq(target.data).cpu().sum()
5152
print('i:%d loss: %f accuracy: %f' %(i, loss.data[0], correct/float(32)))

show_seg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@
5151

5252
classifier = PointNetDenseCls(k = 4)
5353
classifier.load_state_dict(torch.load(opt.model))
54+
classifier.eval()
5455

5556
point = point.transpose(1,0).contiguous()
5657

5758
point = Variable(point.view(1, point.size()[0], point.size()[1]))
5859
pred, _ = classifier(point)
5960

60-
pred_choice = pred.data.max(2)[1][0,:,0]
61+
pred_choice = pred.data.max(2)[1]
6162
#print(pred_choice.size())
6263
pred_color = cmap[pred_choice.numpy(), :]
6364

train_classification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
print('[%d: %d/%d] train loss: %f accuracy: %f' %(epoch, i, num_batch, loss.data[0], correct/float(opt.batchSize)))
8484

8585
if i % 10 == 0:
86-
j, data = enumerate(testdataloader, 0).next()
86+
j, data = next(enumerate(testdataloader, 0))
8787
points, target = data
8888
points, target = Variable(points), Variable(target[:,0])
8989
points = points.transpose(2,1)

train_segmentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
print('[%d: %d/%d] train loss: %f accuracy: %f' %(epoch, i, num_batch, loss.data[0], correct/float(opt.batchSize * 2500)))
8484

8585
if i % 10 == 0:
86-
j, data = enumerate(testdataloader, 0).next()
86+
j, data = next(enumerate(testdataloader, 0))
8787
points, target = data
8888
points, target = Variable(points), Variable(target)
8989
points = points.transpose(2,1)

0 commit comments

Comments
 (0)