Skip to content

Commit 774f58e

Browse files
committed
no message
1 parent 726b768 commit 774f58e

9 files changed

+39
-49
lines changed

autozoom.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030

3131
##########################################################
3232

33-
assert(int(str('').join(torch.__version__.split('.')[0:2])) >= 12) # requires at least pytorch version 1.2.0
34-
3533
torch.set_grad_enabled(False) # make sure to not compute gradients for computational performance
3634

3735
torch.backends.cudnn.enabled = True # make sure to use cudnn for computational performance
@@ -94,5 +92,5 @@
9492
'boolInpaint': True
9593
})
9694

97-
moviepy.editor.ImageSequenceClip(sequence=[ npyFrame[:, :, ::-1] for npyFrame in npyResult + list(reversed(npyResult))[1:] ], fps=25).write_videofile(arguments_strOut)
95+
moviepy.editor.ImageSequenceClip(sequence=[ npyFrame[:, :, ::-1] for npyFrame in npyResult + list(reversed(npyResult))[1:-1] ], fps=25).write_videofile(arguments_strOut)
9896
# end

benchmark-ibims.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929

3030
##########################################################
3131

32-
assert(int(str('').join(torch.__version__.split('.')[0:2])) >= 12) # requires at least pytorch version 1.2.0
33-
3432
torch.set_grad_enabled(False) # make sure to not compute gradients for computational performance
3533

3634
torch.backends.cudnn.enabled = True # make sure to use cudnn for computational performance
@@ -113,20 +111,20 @@
113111

114112
if objMat['mask_wall_paras'][0][0].size > 0:
115113
pe_fla_wall, pe_ori_wall = compute_planarity_error(objMat['depth'][0][0] * valid, pred * valid, objMat['mask_wall_paras'][0][0], objMat['mask_wall'][0][0] * valid, objMat['calib'][0][0])
116-
pe_fla.extend(pe_fla_wall.tolist())
117-
pe_ori.extend(pe_ori_wall.tolist())
114+
pe_fla += pe_fla_wall.tolist()
115+
pe_ori += pe_ori_wall.tolist()
118116
# end
119117

120118
if objMat['mask_table_paras'][0][0].size > 0:
121119
pe_fla_table, pe_ori_table = compute_planarity_error(objMat['depth'][0][0] * valid, pred * valid, objMat['mask_table_paras'][0][0], objMat['mask_table'][0][0] * valid, objMat['calib'][0][0])
122-
pe_fla.extend(pe_fla_table.tolist())
123-
pe_ori.extend(pe_ori_table.tolist())
120+
pe_fla += pe_fla_table.tolist()
121+
pe_ori += pe_ori_table.tolist()
124122
# end
125123

126124
if objMat['mask_floor_paras'][0][0].size > 0:
127125
pe_fla_floor, pe_ori_floor = compute_planarity_error(objMat['depth'][0][0] * valid, pred * valid, objMat['mask_floor_paras'][0][0], objMat['mask_floor'][0][0] * valid, objMat['calib'][0][0])
128-
pe_fla.extend(pe_fla_floor.tolist())
129-
pe_ori.extend(pe_ori_floor.tolist())
126+
pe_fla += pe_fla_floor.tolist()
127+
pe_ori += pe_ori_floor.tolist()
130128
# end
131129
# end
132130
# end

benchmark-nyu.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929

3030
##########################################################
3131

32-
assert(int(str('').join(torch.__version__.split('.')[0:2])) >= 12) # requires at least pytorch version 1.2.0
33-
3432
torch.set_grad_enabled(False) # make sure to not compute gradients for computational performance
3533

3634
torch.backends.cudnn.enabled = True # make sure to use cudnn for computational performance

common.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ def process_inpaint(tenShift):
4040

4141
tenMask = (objInpainted['tenExisting'] == 0.0).view(1, 1, -1)
4242

43-
objCommon['tenInpaImage'] = torch.cat([ objCommon['tenInpaImage'], objInpainted['tenImage'].view(1, 3, -1)[tenMask.expand(-1, 3, -1)].view(1, 3, -1) ], 2)
44-
objCommon['tenInpaDisparity'] = torch.cat([ objCommon['tenInpaDisparity'], objInpainted['tenDisparity'].view(1, 1, -1)[tenMask.expand(-1, 1, -1)].view(1, 1, -1) ], 2)
45-
objCommon['tenInpaDepth'] = torch.cat([ objCommon['tenInpaDepth'], objInpainted['tenDepth'].view(1, 1, -1)[tenMask.expand(-1, 1, -1)].view(1, 1, -1) ], 2)
46-
objCommon['tenInpaPoints'] = torch.cat([ objCommon['tenInpaPoints'], objInpainted['tenPoints'].view(1, 3, -1)[tenMask.expand(-1, 3, -1)].view(1, 3, -1) ], 2)
43+
objCommon['tenInpaImage'] = torch.cat([ objCommon['tenInpaImage'], objInpainted['tenImage'].view(1, 3, -1)[tenMask.repeat(1, 3, 1)].view(1, 3, -1) ], 2)
44+
objCommon['tenInpaDisparity'] = torch.cat([ objCommon['tenInpaDisparity'], objInpainted['tenDisparity'].view(1, 1, -1)[tenMask.repeat(1, 1, 1)].view(1, 1, -1) ], 2)
45+
objCommon['tenInpaDepth'] = torch.cat([ objCommon['tenInpaDepth'], objInpainted['tenDepth'].view(1, 1, -1)[tenMask.repeat(1, 1, 1)].view(1, 1, -1) ], 2)
46+
objCommon['tenInpaPoints'] = torch.cat([ objCommon['tenInpaPoints'], objInpainted['tenPoints'].view(1, 3, -1)[tenMask.repeat(1, 3, 1)].view(1, 3, -1) ], 2)
4747
# end
4848

4949
def process_shift(objSettings):
@@ -290,20 +290,18 @@ def preprocess_kernel(strKernel, objVariables):
290290
@cupy.memoize(for_each_device=True)
291291
def launch_kernel(strFunction, strKernel):
292292
if 'CUDA_HOME' not in os.environ:
293-
os.environ['CUDA_HOME'] = sorted(glob.glob('/usr/lib/cuda*') + glob.glob('/usr/local/cuda*'))[-1]
293+
os.environ['CUDA_HOME'] = cupy.cuda.get_cuda_path()
294294
# end
295295

296296
return cupy.cuda.compile_with_cache(strKernel, tuple([ '-I ' + os.environ['CUDA_HOME'], '-I ' + os.environ['CUDA_HOME'] + '/include' ])).get_function(strFunction)
297297
# end
298298

299299
def depth_to_points(tenDepth, fltFocal):
300-
tenHorizontal = torch.linspace((-0.5 * tenDepth.shape[3]) + 0.5, (0.5 * tenDepth.shape[3]) - 0.5, tenDepth.shape[3]).view(1, 1, 1, -1).expand(tenDepth.shape[0], -1, tenDepth.shape[2], -1)
300+
tenHorizontal = torch.linspace(start=(-0.5 * tenDepth.shape[3]) + 0.5, end=(0.5 * tenDepth.shape[3]) - 0.5, steps=tenDepth.shape[3], dtype=tenDepth.dtype, device=tenDepth.device).view(1, 1, 1, -1).repeat(tenDepth.shape[0], 1, tenDepth.shape[2], 1)
301301
tenHorizontal = tenHorizontal * (1.0 / fltFocal)
302-
tenHorizontal = tenHorizontal.type_as(tenDepth)
303302

304-
tenVertical = torch.linspace((-0.5 * tenDepth.shape[2]) + 0.5, (0.5 * tenDepth.shape[2]) - 0.5, tenDepth.shape[2]).view(1, 1, -1, 1).expand(tenDepth.shape[0], -1, -1, tenDepth.shape[3])
303+
tenVertical = torch.linspace(start=(-0.5 * tenDepth.shape[2]) + 0.5, end=(0.5 * tenDepth.shape[2]) - 0.5, steps=tenDepth.shape[2], dtype=tenDepth.dtype, device=tenDepth.device).view(1, 1, -1, 1).repeat(tenDepth.shape[0], 1, 1, tenDepth.shape[3])
305304
tenVertical = tenVertical * (1.0 / fltFocal)
306-
tenVertical = tenVertical.type_as(tenDepth)
307305

308306
return torch.cat([ tenDepth * tenHorizontal, tenDepth * tenVertical, tenDepth ], 1)
309307
# end
@@ -401,23 +399,23 @@ def render_pointcloud(tenInput, tenData, intWidth, intHeight, fltFocal, fltBasel
401399
float fltSouthwest = (intNortheastX - fltOutputX) * (fltOutputY - intNortheastY);
402400
float fltSoutheast = (fltOutputX - intNorthwestX) * (fltOutputY - intNorthwestY);
403401
404-
if ((fltNorthwest >= fltNortheast) & (fltNorthwest >= fltSouthwest) & (fltNorthwest >= fltSoutheast)) {
405-
if ((intNorthwestX >= 0) & (intNorthwestX < SIZE_3(zee)) & (intNorthwestY >= 0) & (intNorthwestY < SIZE_2(zee))) {
402+
if ((fltNorthwest >= fltNortheast) && (fltNorthwest >= fltSouthwest) && (fltNorthwest >= fltSoutheast)) {
403+
if ((intNorthwestX >= 0) && (intNorthwestX < SIZE_3(zee)) && (intNorthwestY >= 0) && (intNorthwestY < SIZE_2(zee))) {
406404
atomicMin(&zee[OFFSET_4(zee, intSample, 0, intNorthwestY, intNorthwestX)], fltError);
407405
}
408406
409-
} else if ((fltNortheast >= fltNorthwest) & (fltNortheast >= fltSouthwest) & (fltNortheast >= fltSoutheast)) {
410-
if ((intNortheastX >= 0) & (intNortheastX < SIZE_3(zee)) & (intNortheastY >= 0) & (intNortheastY < SIZE_2(zee))) {
407+
} else if ((fltNortheast >= fltNorthwest) && (fltNortheast >= fltSouthwest) && (fltNortheast >= fltSoutheast)) {
408+
if ((intNortheastX >= 0) && (intNortheastX < SIZE_3(zee)) && (intNortheastY >= 0) && (intNortheastY < SIZE_2(zee))) {
411409
atomicMin(&zee[OFFSET_4(zee, intSample, 0, intNortheastY, intNortheastX)], fltError);
412410
}
413411
414-
} else if ((fltSouthwest >= fltNorthwest) & (fltSouthwest >= fltNortheast) & (fltSouthwest >= fltSoutheast)) {
415-
if ((intSouthwestX >= 0) & (intSouthwestX < SIZE_3(zee)) & (intSouthwestY >= 0) & (intSouthwestY < SIZE_2(zee))) {
412+
} else if ((fltSouthwest >= fltNorthwest) && (fltSouthwest >= fltNortheast) && (fltSouthwest >= fltSoutheast)) {
413+
if ((intSouthwestX >= 0) && (intSouthwestX < SIZE_3(zee)) && (intSouthwestY >= 0) && (intSouthwestY < SIZE_2(zee))) {
416414
atomicMin(&zee[OFFSET_4(zee, intSample, 0, intSouthwestY, intSouthwestX)], fltError);
417415
}
418416
419-
} else if ((fltSoutheast >= fltNorthwest) & (fltSoutheast >= fltNortheast) & (fltSoutheast >= fltSouthwest)) {
420-
if ((intSoutheastX >= 0) & (intSoutheastX < SIZE_3(zee)) & (intSoutheastY >= 0) & (intSoutheastY < SIZE_2(zee))) {
417+
} else if ((fltSoutheast >= fltNorthwest) && (fltSoutheast >= fltNortheast) && (fltSoutheast >= fltSouthwest)) {
418+
if ((intSoutheastX >= 0) && (intSoutheastX < SIZE_3(zee)) && (intSoutheastY >= 0) && (intSoutheastY < SIZE_2(zee))) {
421419
atomicMin(&zee[OFFSET_4(zee, intSample, 0, intSoutheastY, intSoutheastX)], fltError);
422420
}
423421
@@ -554,31 +552,31 @@ def render_pointcloud(tenInput, tenData, intWidth, intHeight, fltFocal, fltBasel
554552
float fltSouthwest = (intNortheastX - fltOutputX) * (fltOutputY - intNortheastY);
555553
float fltSoutheast = (fltOutputX - intNorthwestX) * (fltOutputY - intNorthwestY);
556554
557-
if ((intNorthwestX >= 0) & (intNorthwestX < SIZE_3(output)) & (intNorthwestY >= 0) & (intNorthwestY < SIZE_2(output))) {
555+
if ((intNorthwestX >= 0) && (intNorthwestX < SIZE_3(output)) && (intNorthwestY >= 0) && (intNorthwestY < SIZE_2(output))) {
558556
if (fltError <= VALUE_4(zee, intSample, 0, intNorthwestY, intNorthwestX) + 1.0) {
559557
for (int intData = 0; intData < SIZE_1(data); intData += 1) {
560558
atomicAdd(&output[OFFSET_4(output, intSample, intData, intNorthwestY, intNorthwestX)], VALUE_3(data, intSample, intData, intPoint) * fltNorthwest);
561559
}
562560
}
563561
}
564562
565-
if ((intNortheastX >= 0) & (intNortheastX < SIZE_3(output)) & (intNortheastY >= 0) & (intNortheastY < SIZE_2(output))) {
563+
if ((intNortheastX >= 0) && (intNortheastX < SIZE_3(output)) && (intNortheastY >= 0) && (intNortheastY < SIZE_2(output))) {
566564
if (fltError <= VALUE_4(zee, intSample, 0, intNortheastY, intNortheastX) + 1.0) {
567565
for (int intData = 0; intData < SIZE_1(data); intData += 1) {
568566
atomicAdd(&output[OFFSET_4(output, intSample, intData, intNortheastY, intNortheastX)], VALUE_3(data, intSample, intData, intPoint) * fltNortheast);
569567
}
570568
}
571569
}
572570
573-
if ((intSouthwestX >= 0) & (intSouthwestX < SIZE_3(output)) & (intSouthwestY >= 0) & (intSouthwestY < SIZE_2(output))) {
571+
if ((intSouthwestX >= 0) && (intSouthwestX < SIZE_3(output)) && (intSouthwestY >= 0) && (intSouthwestY < SIZE_2(output))) {
574572
if (fltError <= VALUE_4(zee, intSample, 0, intSouthwestY, intSouthwestX) + 1.0) {
575573
for (int intData = 0; intData < SIZE_1(data); intData += 1) {
576574
atomicAdd(&output[OFFSET_4(output, intSample, intData, intSouthwestY, intSouthwestX)], VALUE_3(data, intSample, intData, intPoint) * fltSouthwest);
577575
}
578576
}
579577
}
580578
581-
if ((intSoutheastX >= 0) & (intSoutheastX < SIZE_3(output)) & (intSoutheastY >= 0) & (intSoutheastY < SIZE_2(output))) {
579+
if ((intSoutheastX >= 0) && (intSoutheastX < SIZE_3(output)) && (intSoutheastY >= 0) && (intSoutheastY < SIZE_2(output))) {
582580
if (fltError <= VALUE_4(zee, intSample, 0, intSoutheastY, intSoutheastX) + 1.0) {
583581
for (int intData = 0; intData < SIZE_1(data); intData += 1) {
584582
atomicAdd(&output[OFFSET_4(output, intSample, intData, intSoutheastY, intSoutheastX)], VALUE_3(data, intSample, intData, intPoint) * fltSoutheast);

depthestim.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030

3131
##########################################################
3232

33-
assert(int(str('').join(torch.__version__.split('.')[0:2])) >= 12) # requires at least pytorch version 1.2.0
34-
3533
torch.set_grad_enabled(False) # make sure to not compute gradients for computational performance
3634

3735
torch.backends.cudnn.enabled = True # make sure to use cudnn for computational performance

interface.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030

3131
##########################################################
3232

33-
assert(int(str('').join(torch.__version__.split('.')[0:2])) >= 12) # requires at least pytorch version 1.2.0
34-
3533
torch.set_grad_enabled(False) # make sure to not compute gradients for computational performance
3634

3735
torch.backends.cudnn.enabled = True # make sure to use cudnn for computational performance
@@ -191,7 +189,7 @@ def generator():
191189
def get_result():
192190
strTempdir = tempfile.gettempdir() + '/kenburns-' + str(os.getpid()) + '-' + str.join('', [ random.choice('abcdefghijklmnopqrstuvwxyz0123456789') for intCount in range(8) ]) + '-' + str(time.time()).split('.')[-1]
193191

194-
os.makedirs(strTempdir + '/')
192+
os.makedirs(name=strTempdir + '/', exist_ok=False)
195193

196194
npyKenburns = process_kenburns({
197195
'fltSteps': numpy.linspace(0.0, 1.0, 75).tolist(),
@@ -200,7 +198,7 @@ def get_result():
200198
'boolInpaint': True
201199
})
202200

203-
moviepy.editor.ImageSequenceClip(sequence=[ npyFrame[:, :, ::-1] for npyFrame in npyKenburns + list(reversed(npyKenburns))[1:] ], fps=25).write_videofile(strTempdir + '/kenburns.mp4')
201+
moviepy.editor.ImageSequenceClip(sequence=[ npyFrame[:, :, ::-1] for npyFrame in npyKenburns + list(reversed(npyKenburns))[1:-1] ], fps=25).write_videofile(strTempdir + '/kenburns.mp4')
204202

205203
objKenburns = io.BytesIO(open(strTempdir + '/kenburns.mp4', 'rb').read())
206204

@@ -209,4 +207,6 @@ def get_result():
209207
return flask.send_file(filename_or_fp=objKenburns, mimetype='video/mp4', as_attachment=True, attachment_filename='kenburns.mp4', cache_timeout=-1)
210208
# end
211209

212-
gevent.pywsgi.WSGIServer(listener=('0.0.0.0', 8080), application=objFlask).serve_forever()
210+
if __name__ == '__main__':
211+
gevent.pywsgi.WSGIServer(listener=('0.0.0.0', 8080), application=objFlask).serve_forever()
212+
# end

models/disparity-adjustment.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ def disparity_adjustment(tenImage, tenDisparity):
6363

6464
if tenPlane.sum().item() == 0: continue
6565

66-
intLeft = (tenPlane.sum(2, True) > 0.0).flatten().nonzero()[0].item()
67-
intTop = (tenPlane.sum(3, True) > 0.0).flatten().nonzero()[0].item()
68-
intRight = (tenPlane.sum(2, True) > 0.0).flatten().nonzero()[-1].item()
69-
intBottom = (tenPlane.sum(3, True) > 0.0).flatten().nonzero()[-1].item()
66+
intLeft = (tenPlane.sum([2], True) > 0.0).flatten().nonzero()[0].item()
67+
intTop = (tenPlane.sum([3], True) > 0.0).flatten().nonzero()[0].item()
68+
intRight = (tenPlane.sum([2], True) > 0.0).flatten().nonzero()[-1].item()
69+
intBottom = (tenPlane.sum([3], True) > 0.0).flatten().nonzero()[-1].item()
7070

7171
tenAdjusted = ((1.0 - tenAdjust) * tenAdjusted) + (tenAdjust * tenPlane[:, :, int(round(intTop + (0.97 * (intBottom - intTop)))):, :].max())
7272
# end

models/disparity-refinement.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def __init__(self):
9191
# end
9292

9393
def forward(self, tenImage, tenDisparity):
94-
tenMean = [ tenImage.view(tenImage.shape[0], -1).mean(1, True).view(tenImage.shape[0], 1, 1, 1), tenDisparity.view(tenDisparity.shape[0], -1).mean(1, True).view(tenDisparity.shape[0], 1, 1, 1) ]
95-
tenStd = [ tenImage.view(tenImage.shape[0], -1).std(1, True).view(tenImage.shape[0], 1, 1, 1), tenDisparity.view(tenDisparity.shape[0], -1).std(1, True).view(tenDisparity.shape[0], 1, 1, 1) ]
94+
tenMean = [ tenImage.mean([1, 2, 3], True), tenDisparity.mean([1, 2, 3], True) ]
95+
tenStd = [ tenImage.std([1, 2, 3], False, True), tenDisparity.std([1, 2, 3], False, True) ]
9696

9797
tenImage = tenImage.clone()
9898
tenImage -= tenMean[0]

models/pointcloud-inpainting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ def forward(self, tenImage, tenDisparity, tenShift):
115115
tenPoints = depth_to_points(tenDepth * tenValid, objCommon['fltFocal'])
116116
tenPoints = tenPoints.view(1, 3, -1)
117117

118-
tenMean = [ tenImage.view(tenImage.shape[0], -1).mean(1, True).view(tenImage.shape[0], 1, 1, 1), tenDisparity.view(tenDisparity.shape[0], -1).mean(1, True).view(tenDisparity.shape[0], 1, 1, 1) ]
119-
tenStd = [ tenImage.view(tenImage.shape[0], -1).std(1, True).view(tenImage.shape[0], 1, 1, 1), tenDisparity.view(tenDisparity.shape[0], -1).std(1, True).view(tenDisparity.shape[0], 1, 1, 1) ]
118+
tenMean = [ tenImage.mean([1, 2, 3], True), tenDisparity.mean([1, 2, 3], True) ]
119+
tenStd = [ tenImage.std([1, 2, 3], False, True), tenDisparity.std([1, 2, 3], False, True) ]
120120

121121
tenImage = tenImage.clone()
122122
tenImage -= tenMean[0]

0 commit comments

Comments
 (0)