20
20
from train_sample import build_graph as build_graph_sample
21
21
from planenet import PlaneNet
22
22
from RecordReaderAll import *
23
+ from RecordReaderMake3D import *
23
24
#from RecordReaderRGBD import *
24
25
from SegmentationRefinement import *
25
26
import scipy .io as sio
34
35
#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')]
35
36
36
37
37
- ALL_TITLES = ['planenet' , 'pixelwise' , 'fine-tuning' , 'ScanNet' ]
38
+ ALL_TITLES = ['planenet' , 'pixelwise' , 'fine-tuning' , 'ScanNet' , 'Make3D' ]
38
39
#ALL_METHODS = [('bl0_ll1_bw0.5_pp_ps_sm0', ''), ('bl0_ll1_bw0.5_pp_ps_sm0', 'pixelwise_1')]
39
40
#ALL_METHODS = [('planenet_hybrid1_bl0_ll1_ds0_pp_ps', ''), ('pixelwise_hybrid1_ps', 'pixelwise_1')]
40
41
#ALL_TITLES = ['crf', 'different matching']
41
42
#ALL_METHODS = [('pb_pp_sm0', 'crf'), ('pb_pp_sm0', '')]
42
43
43
44
#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' , '' ) ]
45
46
46
47
def writeHTML (options ):
47
48
from html import HTML
@@ -1053,7 +1054,6 @@ def getPredictionHighRes(options):
1053
1054
options .batchSize = 1
1054
1055
min_after_dequeue = 1000
1055
1056
1056
- reader = RecordReaderAll ()
1057
1057
if options .dataset == 'SUNCG' :
1058
1058
filename_queue = tf .train .string_input_producer (['/mnt/vision/PlaneNet/planes_SUNCG_val.tfrecords' ], num_epochs = 10000 )
1059
1059
elif options .dataset == 'NYU_RGBD_raw' :
@@ -1066,6 +1066,14 @@ def getPredictionHighRes(options):
1066
1066
filename_queue = tf .train .string_input_producer (['/mnt/vision/PlaneNet/planes_scannet_val.tfrecords' ], num_epochs = 1 )
1067
1067
elif options .dataset == 'NYU_RGBD' :
1068
1068
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 ()
1069
1077
pass
1070
1078
1071
1079
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):
1338
1346
options .batchSize = 1
1339
1347
min_after_dequeue = 1000
1340
1348
1341
- reader = RecordReaderAll ()
1342
1349
if options .dataset == 'SUNCG' :
1343
1350
filename_queue = tf .train .string_input_producer (['/mnt/vision/PlaneNet/planes_SUNCG_val.tfrecords' ], num_epochs = 10000 )
1344
1351
elif options .dataset == 'NYU_RGBD_raw' :
@@ -1351,6 +1358,14 @@ def getGroundTruthHighRes(options):
1351
1358
filename_queue = tf .train .string_input_producer (['/mnt/vision/PlaneNet/planes_scannet_val.tfrecords' ], num_epochs = 1 )
1352
1359
elif options .dataset == 'NYU_RGBD' :
1353
1360
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 ()
1354
1369
pass
1355
1370
1356
1371
@@ -1418,9 +1433,20 @@ def getGroundTruthHighRes(options):
1418
1433
1419
1434
imagePath = global_gt ['image_path' ][0 ]
1420
1435
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
1424
1450
1425
1451
images .append (image )
1426
1452
gtDepths .append (gt_d )
@@ -1520,7 +1546,6 @@ def evaluateAll(options):
1520
1546
options .batchSize = 1
1521
1547
min_after_dequeue = 1000
1522
1548
1523
- reader = RecordReaderAll ()
1524
1549
if options .dataset == 'SUNCG' :
1525
1550
filename_queue = tf .train .string_input_producer (['/mnt/vision/PlaneNet/planes_SUNCG_val.tfrecords' ], num_epochs = 10000 )
1526
1551
elif options .dataset == 'NYU_RGBD_raw' :
@@ -1533,6 +1558,14 @@ def evaluateAll(options):
1533
1558
filename_queue = tf .train .string_input_producer (['/mnt/vision/PlaneNet/planes_scannet_val.tfrecords' ], num_epochs = 1 )
1534
1559
elif options .dataset == 'NYU_RGBD' :
1535
1560
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 ()
1536
1569
pass
1537
1570
1538
1571
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):
1598
1631
continue
1599
1632
1600
1633
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
-
1618
1634
info = global_gt ['info' ][0 ]
1619
1635
1620
1636
width_high_res = int (info [16 ])
@@ -1656,6 +1672,49 @@ def evaluateAll(options):
1656
1672
#all_normals = np.concatenate([plane_normals, np.expand_dims(pred_np_n, 2)], axis=2)
1657
1673
#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))
1658
1674
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
+
1659
1718
planeMask = gt_s < options .numOutputPlanes
1660
1719
edgeMap = calcEdgeMap (gt_s , edgeWidth = 5 )
1661
1720
if edgeMap .sum () == 0 :
@@ -1683,11 +1742,6 @@ def evaluateAll(options):
1683
1742
pixelwise_results .append (pixelwise_result )
1684
1743
#exit(1)
1685
1744
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
1691
1745
#cv2.imwrite('test/mask.png', drawMaskImage(edgeMap))
1692
1746
1693
1747
#predDepthNormals.append(calcNormal(pred_d, info))
@@ -1780,7 +1834,7 @@ def evaluateAll(options):
1780
1834
1781
1835
args = parser .parse_args ()
1782
1836
#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
1784
1838
if args .highRes == 1 :
1785
1839
args .test_dir += '_high_res'
1786
1840
args .width = 561
0 commit comments