Skip to content

Commit

Permalink
Fix 3D bug in display+larcv interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Temigo committed Apr 12, 2018
1 parent 1607b29 commit 52862ea
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
v0.1.1, 3/30/2018 -- Initial release.

v0.2.0, 4/9/2018 -- 3D version of PPN initial release.

v0.2.1, 4/12/2018 -- Correct 3D bugs in display and larcv interface.
4 changes: 4 additions & 0 deletions faster_particles/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

os.environ['CUDA_DEVICE_ORDER'] = 'PCI_BUS_ID'
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2,3'
# Control Tensorflow verbose level with TF_CPP_MIN_LOG_LEVEL
# it defaults to 0 (all logs shown), but can be set to 1 to filter out INFO logs,
# 2 to additionally filter out WARNING logs, and 3 to additionally filter out ERROR logs
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '1'

class PPNConfig(object):
IMAGE_SIZE = 768 # 512
Expand Down
9 changes: 5 additions & 4 deletions faster_particles/demo_ppn.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def display(blob, cfg, im_proposals=None, rois=None, im_labels=None, im_scores=N
# Display original image
if cfg.DATA_3D:
for voxel in blob['voxels']:
draw_voxel(voxel[2], voxel[1], voxel[0], 1, ax, facecolors='blue', alpha=0.3, linewidths=0.1, edgecolors='black')
draw_voxel(voxel[0], voxel[1], voxel[2], 1, ax, facecolors='blue', alpha=0.3, linewidths=0.1, edgecolors='black')
else:
ax.imshow(blob['data'][0,...,0], cmap='jet', interpolation='none', origin='lower', vmin=0, vmax=400)

Expand Down Expand Up @@ -137,9 +137,9 @@ def display(blob, cfg, im_proposals=None, rois=None, im_labels=None, im_scores=N
# Display original image
if cfg.DATA_3D:
for voxel in blob['voxels']:
draw_voxel(voxel[2], voxel[1], voxel[0], 1, ax2, facecolors='blue', alpha=0.3, linewidths=0.1, edgecolors='black')
draw_voxel(voxel[0], voxel[1], voxel[2], 1, ax2, facecolors='blue', alpha=0.3, linewidths=0.1, edgecolors='black')
else:
ax.imshow(blob['data'][0,...,0], cmap='jet', interpolation='none', origin='lower', vmin=0, vmax=400)
ax2.imshow(blob['data'][0,...,0], cmap='jet', interpolation='none', origin='lower', vmin=0, vmax=400)

if im_proposals is not None and im_scores is not None:
if len(im_proposals) > 0:
Expand Down Expand Up @@ -170,6 +170,7 @@ def display(blob, cfg, im_proposals=None, rois=None, im_labels=None, im_scores=N
# Use dpi=1000 for high resolution
plt.savefig(os.path.join(cfg.DISPLAY_DIR, name + '_predictions_%d.png' % index))
plt.close(fig2)
print(im_proposals)
return im_proposals

"""if cfg.DATA_3D and im_proposals is not None and im_scores is not None:
Expand Down Expand Up @@ -282,7 +283,7 @@ def inference(cfg):
im_proposals, im_labels, im_scores, distances = [], [], [], []
with tf.Session() as sess:
saver.restore(sess, cfg.WEIGHTS_FILE)
for i in range(100):
for i in range(10):
blob = data.forward()
summary, results = net.test_image(sess, blob)
if cfg.NET == 'ppn':
Expand Down
4 changes: 2 additions & 2 deletions faster_particles/larcvdata/larcvdata_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@ def forward(self):
y = t_points[ 3*pt_index + 1 ]
z = t_points[ 3*pt_index + 2 ]
if x < 0: break
gt_pixels.append([x, y, z, 1])
gt_pixels.append([z, y, x, 1])
for pt_index in np.arange(int(len(s_points)/3)):
x = s_points[ 3*pt_index ]
y = s_points[ 3*pt_index + 1 ]
z = s_points[ 3*pt_index + 2 ]
if x < 0: break
gt_pixels.append([x, y, z, 2])
gt_pixels.append([z, y, x, 2])
else:
for pt_index in np.arange(int(len(t_points)/2)):
x = t_points[ 2*pt_index ]
Expand Down
5 changes: 0 additions & 5 deletions faster_particles/ppn.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ def create_architecture(self, is_training=True, reuse=None, scope="ppn"):

# Build PPN1
rois = self.build_ppn1(net2)
#print("rois", rois.get_shape().as_list())
rois = slice_rois(rois, self.dim2)
#print("rois", rois.get_shape().as_list())

if self.is_training:
# During training time, check if all ground truth pixels are covered by ROIs
Expand Down Expand Up @@ -239,7 +237,6 @@ def build_ppn1(self, net2):
# Compute softmax
# Shape of ppn1_cls_prob = 1, 16, 16, 2
ppn1_cls_prob = tf.nn.softmax(ppn1_cls_score)
print("ppn1_cls_score ", ppn1_cls_score.get_shape().as_list())

# Step 3) Get a (meaningful) subset of rois and associated scores
# Generate anchors = pixel centers of the last feature map.
Expand All @@ -251,7 +248,6 @@ def build_ppn1(self, net2):
# and anchors. Take the first R proposed pixels which contain an object.
proposals, scores = predicted_pixels(ppn1_cls_prob, ppn1_pixel_pred, anchors, (self.N2,) * self.dim)
rois, roi_scores = top_R_pixels(proposals, scores, R=20, threshold=self.ppn1_score_threshold)
print("final proposals ", proposals.get_shape().as_list())
assert proposals.get_shape().as_list() == [self.N3**self.dim, self.dim]
assert scores.get_shape().as_list() == [self.N3**self.dim, 1]
#assert rois.get_shape().as_list() == [None, 2]
Expand Down Expand Up @@ -315,7 +311,6 @@ def build_ppn2(self, rpn_pooling, rois):
# Step 0) Convolution for PPN2 intermediate layer
# Based on F3 feature map (ie after 3 max-pool layers in VGG)
# Shape = nb_rois, 1, 1, 512
print("rpn_pooling", rpn_pooling)
ppn2 = self.conv(rpn_pooling,
self.ppn2_channels, # RPN Channels = num_outputs
3, # RPN Kernels FIXME change this to (1, 1)?
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='faster-particles',
version='0.2.0',
version='0.2.1',
author='Laura Domine, Ji Won Park, Kazuhiro Terao',
author_email='temigo@gmx.com',
packages=find_packages(),
Expand Down

0 comments on commit 52862ea

Please sign in to comment.