Skip to content

Commit e270268

Browse files
minor changes
2 parents 15439b3 + 6db381a commit e270268

9 files changed

+1183
-1191
lines changed

code/evaluate.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import time
77
import sys
8-
import tf_nndistance
8+
#import tf_nndistance
99
import argparse
1010
import glob
1111
import PIL
@@ -23,6 +23,8 @@
2323
from SegmentationRefinement import *
2424
from crfasrnn_layer import CrfRnnLayer
2525

26+
#['/mnt/vision/ScanNet/data/scene0164_01/frames/frame-000068.color.jpg']
27+
2628
#ALL_TITLES = ['planenet', 'pixelwise', 'pixelwise+RANSAC', 'depth observation+RANSAC', 'pixelwise+semantics+RANSAC', 'gt']
2729
#ALL_METHODS = [('bl2_ll1_bw0.5_pb_pp_sm0', ''), ('pb_pp', 'pixelwise_1'), ('pb_pp', 'pixelwise_2'), ('pb_pp', 'pixelwise_3'), ('pb_pp', 'semantics'), ('pb_pp', 'gt')]
2830

@@ -1394,7 +1396,7 @@ def getPrediction(options):
13941396
elif options.dataset == 'matterport':
13951397
filename_queue = tf.train.string_input_producer(['/mnt/vision/PlaneNet/planes_matterport_val.tfrecords'], num_epochs=1)
13961398
else:
1397-
filename_queue = tf.train.string_input_producer(['/mnt/vision/PlaneNet/planes_scannet_val.tfrecords'], num_epochs=1)
1399+
filename_queue = tf.train.string_input_producer(['/mnt/vision/Data/PlaneNet/planes_scannet_val.tfrecords'], num_epochs=1)
13981400
pass
13991401

14001402
img_inp, global_gt_dict, local_gt_dict = reader.getBatch(filename_queue, numOutputPlanes=options.numOutputPlanes, batchSize=options.batchSize, min_after_dequeue=min_after_dequeue, getLocal=True, random=False)
@@ -1528,7 +1530,7 @@ def getGroundTruth(options):
15281530
elif options.dataset == 'matterport':
15291531
filename_queue = tf.train.string_input_producer(['/mnt/vision/PlaneNet/planes_matterport_val.tfrecords'], num_epochs=1)
15301532
else:
1531-
filename_queue = tf.train.string_input_producer(['/mnt/vision/PlaneNet/planes_scannet_val.tfrecords'], num_epochs=1)
1533+
filename_queue = tf.train.string_input_producer(['/mnt/vision/Data/PlaneNet/planes_scannet_val.tfrecords'], num_epochs=1)
15321534
pass
15331535

15341536

@@ -1583,8 +1585,11 @@ def getGroundTruth(options):
15831585
if index < options.startIndex:
15841586
continue
15851587

1586-
1587-
# print(global_gt['path'])
1588+
if index == 100:
1589+
print(global_gt['image_path'])
1590+
exit(1)
1591+
pass
1592+
continue
15881593
# if index == 11:
15891594
# cv2.imwrite('test/mask.png', drawMaskImage(global_gt['non_plane_mask'].squeeze()))
15901595
# exit(1)

code/evaluate_depth.py

+85-31
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from train_sample import build_graph as build_graph_sample
2121
from planenet import PlaneNet
2222
from RecordReaderAll import *
23+
from RecordReaderMake3D import *
2324
#from RecordReaderRGBD import *
2425
from SegmentationRefinement import *
2526
import scipy.io as sio
@@ -34,14 +35,14 @@
3435
#ALL_METHODS = [('ll1_pb_pp', 'pixelwise_1'), ('crf1_pb_pp', 'pixelwise_2'), ('bl0_ll1_bw0.5_pb_pp_ps_sm0', 'pixelwise_3'), ('ll1_bw0.5_pb_pp_sm0', 'pixelwise_4')]
3536

3637

37-
ALL_TITLES = ['planenet', 'pixelwise', 'fine-tuning', 'ScanNet']
38+
ALL_TITLES = ['planenet', 'pixelwise', 'fine-tuning', 'ScanNet', 'Make3D']
3839
#ALL_METHODS = [('bl0_ll1_bw0.5_pp_ps_sm0', ''), ('bl0_ll1_bw0.5_pp_ps_sm0', 'pixelwise_1')]
3940
#ALL_METHODS = [('planenet_hybrid1_bl0_ll1_ds0_pp_ps', ''), ('pixelwise_hybrid1_ps', 'pixelwise_1')]
4041
#ALL_TITLES = ['crf', 'different matching']
4142
#ALL_METHODS = [('pb_pp_sm0', 'crf'), ('pb_pp_sm0', '')]
4243

4344
#ALL_METHODS = [('planenet_hybrid1_bl0_ll1_ds0_pp_ps', ''), ('pixelwise_hybrid1_ps', '')]
44-
ALL_METHODS = [('pixelwise_np10_hybrid1_ds0', ''), ('finetuning_hybrid1_ps', ''), ('finetuning_np10_hybrid1_ds0_ps', ''), ('sample_np10_hybrid3_bl0_dl0_ds0_crfrnn5_sm0', '')]
45+
ALL_METHODS = [('pixelwise_np10_hybrid1_ds0', ''), ('finetuning_hybrid1_ps', ''), ('finetuning_np10_hybrid1_ds0_ps', ''), ('sample_np10_hybrid3_bl0_dl0_ds0_crfrnn5_sm0', ''), ('finetuning_np10_hybrid4_ds0', '')]
4546

4647
def writeHTML(options):
4748
from html import HTML
@@ -1053,7 +1054,6 @@ def getPredictionHighRes(options):
10531054
options.batchSize = 1
10541055
min_after_dequeue = 1000
10551056

1056-
reader = RecordReaderAll()
10571057
if options.dataset == 'SUNCG':
10581058
filename_queue = tf.train.string_input_producer(['/mnt/vision/PlaneNet/planes_SUNCG_val.tfrecords'], num_epochs=10000)
10591059
elif options.dataset == 'NYU_RGBD_raw':
@@ -1066,6 +1066,14 @@ def getPredictionHighRes(options):
10661066
filename_queue = tf.train.string_input_producer(['/mnt/vision/PlaneNet/planes_scannet_val.tfrecords'], num_epochs=1)
10671067
elif options.dataset == 'NYU_RGBD':
10681068
filename_queue = tf.train.string_input_producer(['/mnt/vision/PlaneNet/planes_nyu_rgbd_labeled_val.tfrecords'], num_epochs=1)
1069+
elif options.dataset == 'Make3D':
1070+
filename_queue = tf.train.string_input_producer(['../planes_make3d_val.tfrecords'], num_epochs=1)
1071+
pass
1072+
1073+
if options.dataset != 'Make3D':
1074+
reader = RecordReaderAll()
1075+
else:
1076+
reader = RecordReaderMake3D()
10691077
pass
10701078

10711079
img_inp, global_gt_dict, local_gt_dict = reader.getBatch(filename_queue, numOutputPlanes=options.numOutputPlanes, batchSize=options.batchSize, min_after_dequeue=min_after_dequeue, getLocal=True, random=False)
@@ -1338,7 +1346,6 @@ def getGroundTruthHighRes(options):
13381346
options.batchSize = 1
13391347
min_after_dequeue = 1000
13401348

1341-
reader = RecordReaderAll()
13421349
if options.dataset == 'SUNCG':
13431350
filename_queue = tf.train.string_input_producer(['/mnt/vision/PlaneNet/planes_SUNCG_val.tfrecords'], num_epochs=10000)
13441351
elif options.dataset == 'NYU_RGBD_raw':
@@ -1351,6 +1358,14 @@ def getGroundTruthHighRes(options):
13511358
filename_queue = tf.train.string_input_producer(['/mnt/vision/PlaneNet/planes_scannet_val.tfrecords'], num_epochs=1)
13521359
elif options.dataset == 'NYU_RGBD':
13531360
filename_queue = tf.train.string_input_producer(['/mnt/vision/PlaneNet/planes_nyu_rgbd_labeled_val.tfrecords'], num_epochs=1)
1361+
elif options.dataset == 'Make3D':
1362+
filename_queue = tf.train.string_input_producer(['../planes_make3d_val.tfrecords'], num_epochs=1)
1363+
pass
1364+
1365+
if options.dataset != 'Make3D':
1366+
reader = RecordReaderAll()
1367+
else:
1368+
reader = RecordReaderMake3D()
13541369
pass
13551370

13561371

@@ -1418,9 +1433,20 @@ def getGroundTruthHighRes(options):
14181433

14191434
imagePath = global_gt['image_path'][0]
14201435

1421-
image = sio.loadmat(imagePath)['imgRgb']
1422-
gt_d = sio.loadmat(imagePath.replace('rgb', 'depth'))['imgDepth']
1423-
gt_n = sio.loadmat(imagePath.replace('images_rgb', 'surface_normals').replace('rgb', 'surface_normals'))['imgNormals']
1436+
1437+
if options.dataset == 'NYU_RGBD':
1438+
image = sio.loadmat(imagePath)['imgRgb']
1439+
gt_d = sio.loadmat(imagePath.replace('rgb', 'depth'))['imgDepth']
1440+
gt_n = sio.loadmat(imagePath.replace('images_rgb', 'surface_normals').replace('rgb', 'surface_normals'))['imgNormals']
1441+
elif options.dataset == 'Make3D':
1442+
image = ((img[0] + 0.5) * 255).astype(np.uint8)
1443+
gt_d = sio.loadmat(imagePath.replace('images', 'depths').replace('img', 'depth').replace('.jpg', '.mat'))['depthMap']
1444+
gt_n = global_gt['normal']
1445+
else:
1446+
image = ((img[0] + 0.5) * 255).astype(np.uint8)
1447+
gt_d = global_gt['depth']
1448+
gt_n = global_gt['normal']
1449+
pass
14241450

14251451
images.append(image)
14261452
gtDepths.append(gt_d)
@@ -1520,7 +1546,6 @@ def evaluateAll(options):
15201546
options.batchSize = 1
15211547
min_after_dequeue = 1000
15221548

1523-
reader = RecordReaderAll()
15241549
if options.dataset == 'SUNCG':
15251550
filename_queue = tf.train.string_input_producer(['/mnt/vision/PlaneNet/planes_SUNCG_val.tfrecords'], num_epochs=10000)
15261551
elif options.dataset == 'NYU_RGBD_raw':
@@ -1533,6 +1558,14 @@ def evaluateAll(options):
15331558
filename_queue = tf.train.string_input_producer(['/mnt/vision/PlaneNet/planes_scannet_val.tfrecords'], num_epochs=1)
15341559
elif options.dataset == 'NYU_RGBD':
15351560
filename_queue = tf.train.string_input_producer(['/mnt/vision/PlaneNet/planes_nyu_rgbd_labeled_val.tfrecords'], num_epochs=1)
1561+
elif options.dataset == 'Make3D':
1562+
filename_queue = tf.train.string_input_producer(['../planes_make3d_val.tfrecords'], num_epochs=1)
1563+
pass
1564+
1565+
if options.dataset != 'Make3D':
1566+
reader = RecordReaderAll()
1567+
else:
1568+
reader = RecordReaderMake3D()
15361569
pass
15371570

15381571
img_inp, global_gt_dict, local_gt_dict = reader.getBatch(filename_queue, numOutputPlanes=options.numOutputPlanes, batchSize=options.batchSize, min_after_dequeue=min_after_dequeue, getLocal=True, random=False)
@@ -1598,23 +1631,6 @@ def evaluateAll(options):
15981631
continue
15991632

16001633

1601-
imagePath = global_gt['image_path'][0]
1602-
1603-
#image = sio.loadmat(imagePath)['imgRgb']
1604-
gt_d = sio.loadmat(imagePath.replace('rgb', 'depth'))['imgDepth']
1605-
#gt_n = sio.loadmat(imagePath.replace('images_rgb', 'surface_normals').replace('rgb', 'surface_normals'))['imgNormals']
1606-
1607-
# images.append(image)
1608-
# gtDepths.append(gt_d)
1609-
# gtNormals.append(gt_n)
1610-
1611-
plane_data = sio.loadmat(imagePath.replace('images_rgb', 'planes').replace('rgb', 'plane_data'))['planeData']
1612-
gt_s = (plane_data[0][0][0] - 1).astype(np.int32)
1613-
planes = plane_data[0][0][1]
1614-
numPlanes = planes.shape[0]
1615-
gt_s[gt_s == numPlanes] = options.numOutputPlanes
1616-
1617-
16181634
info = global_gt['info'][0]
16191635

16201636
width_high_res = int(info[16])
@@ -1656,6 +1672,49 @@ def evaluateAll(options):
16561672
#all_normals = np.concatenate([plane_normals, np.expand_dims(pred_np_n, 2)], axis=2)
16571673
#pred_n = all_normals.reshape(-1, options.numOutputPlanes + 1, 3)[np.arange(width_high_res * height_high_res), segmentation.reshape(-1)].reshape((height_high_res, width_high_res, 3))
16581674

1675+
1676+
imagePath = global_gt['image_path'][0]
1677+
1678+
#image = sio.loadmat(imagePath)['imgRgb']
1679+
1680+
1681+
if options.dataset == 'NYU_RGBD':
1682+
gt_d = sio.loadmat(imagePath.replace('rgb', 'depth'))['imgDepth']
1683+
elif options.dataset == 'Make3D':
1684+
gt_d = sio.loadmat(imagePath.replace('images', 'depths').replace('img', 'depth').replace('.jpg', '.mat'))['depthMap']
1685+
planenet_result = []
1686+
pred_d = cv2.resize(pred_d, (gt_d.shape[1], gt_d.shape[0]))
1687+
planenet_result.append(evaluateDepths(pred_d, gt_d, np.ones(gt_d.shape)))
1688+
planenet_results.append(planenet_result)
1689+
continue
1690+
else:
1691+
gt_d = global_gt['depth']
1692+
pass
1693+
1694+
if index < options.visualizeImages:
1695+
img = sio.loadmat(imagePath)['imgRgb']
1696+
#cv2.imwrite(options.test_dir + '/' + str(index) + '_image.png', ((img[0] + 0.5) * 255).astype(np.uint8))
1697+
cv2.imwrite(options.test_dir + '/' + str(index) + '_image.png', img.astype(np.uint8))
1698+
cv2.imwrite(options.test_dir + '/' + str(index) + '_segmentation.png', drawSegmentationImage(segmentation, blackIndex=options.numOutputPlanes))
1699+
cv2.imwrite(options.test_dir + '/' + str(index) + '_depth_pred.png', drawDepthImage(pred_d))
1700+
cv2.imwrite(options.test_dir + '/' + str(index) + '_depth_gt.png', drawDepthImage(gt_d))
1701+
pass
1702+
1703+
#gt_d = sio.loadmat(imagePath.replace('rgb', 'depth'))['imgDepth']
1704+
1705+
1706+
#gt_n = sio.loadmat(imagePath.replace('images_rgb', 'surface_normals').replace('rgb', 'surface_normals'))['imgNormals']
1707+
1708+
# images.append(image)
1709+
# gtDepths.append(gt_d)
1710+
# gtNormals.append(gt_n)
1711+
1712+
plane_data = sio.loadmat(imagePath.replace('images_rgb', 'planes').replace('rgb', 'plane_data'))['planeData']
1713+
gt_s = (plane_data[0][0][0] - 1).astype(np.int32)
1714+
planes = plane_data[0][0][1]
1715+
numPlanes = planes.shape[0]
1716+
gt_s[gt_s == numPlanes] = options.numOutputPlanes
1717+
16591718
planeMask = gt_s < options.numOutputPlanes
16601719
edgeMap = calcEdgeMap(gt_s, edgeWidth=5)
16611720
if edgeMap.sum() == 0:
@@ -1683,11 +1742,6 @@ def evaluateAll(options):
16831742
pixelwise_results.append(pixelwise_result)
16841743
#exit(1)
16851744

1686-
if index < options.visualizeImages:
1687-
cv2.imwrite(options.test_dir + '/' + str(index) + '_image.png', ((img + 0.5) * 255).astype(np.uint8))
1688-
cv2.imwrite(options.test_dir + '/' + str(index) + '_segmentation.png', drawSegmentationImage(segmentation, blackIndex=options.numOutputPlanes))
1689-
cv2.imwrite(options.test_dir + '/' + str(index) + '_depth.png', drawDepthImage(pred_d))
1690-
continue
16911745
#cv2.imwrite('test/mask.png', drawMaskImage(edgeMap))
16921746

16931747
#predDepthNormals.append(calcNormal(pred_d, info))
@@ -1780,7 +1834,7 @@ def evaluateAll(options):
17801834

17811835
args = parser.parse_args()
17821836
#args.hybrid = 'hybrid' + args.hybrid
1783-
args.test_dir = 'evaluate/' + args.task + '/' + args.dataset + '/hybrid' + args.hybrid
1837+
args.test_dir = 'evaluate/' + args.task + '/' + args.dataset + '/hybrid' + args.hybrid + '_' + args.methods
17841838
if args.highRes == 1:
17851839
args.test_dir += '_high_res'
17861840
args.width = 561

0 commit comments

Comments
 (0)