@@ -40,10 +40,10 @@ def process_inpaint(tenShift):
40
40
41
41
tenMask = (objInpainted ['tenExisting' ] == 0.0 ).view (1 , 1 , - 1 )
42
42
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 )
47
47
# end
48
48
49
49
def process_shift (objSettings ):
@@ -290,20 +290,18 @@ def preprocess_kernel(strKernel, objVariables):
290
290
@cupy .memoize (for_each_device = True )
291
291
def launch_kernel (strFunction , strKernel ):
292
292
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 ()
294
294
# end
295
295
296
296
return cupy .cuda .compile_with_cache (strKernel , tuple ([ '-I ' + os .environ ['CUDA_HOME' ], '-I ' + os .environ ['CUDA_HOME' ] + '/include' ])).get_function (strFunction )
297
297
# end
298
298
299
299
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 )
301
301
tenHorizontal = tenHorizontal * (1.0 / fltFocal )
302
- tenHorizontal = tenHorizontal .type_as (tenDepth )
303
302
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 ])
305
304
tenVertical = tenVertical * (1.0 / fltFocal )
306
- tenVertical = tenVertical .type_as (tenDepth )
307
305
308
306
return torch .cat ([ tenDepth * tenHorizontal , tenDepth * tenVertical , tenDepth ], 1 )
309
307
# end
@@ -401,23 +399,23 @@ def render_pointcloud(tenInput, tenData, intWidth, intHeight, fltFocal, fltBasel
401
399
float fltSouthwest = (intNortheastX - fltOutputX) * (fltOutputY - intNortheastY);
402
400
float fltSoutheast = (fltOutputX - intNorthwestX) * (fltOutputY - intNorthwestY);
403
401
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))) {
406
404
atomicMin(&zee[OFFSET_4(zee, intSample, 0, intNorthwestY, intNorthwestX)], fltError);
407
405
}
408
406
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))) {
411
409
atomicMin(&zee[OFFSET_4(zee, intSample, 0, intNortheastY, intNortheastX)], fltError);
412
410
}
413
411
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))) {
416
414
atomicMin(&zee[OFFSET_4(zee, intSample, 0, intSouthwestY, intSouthwestX)], fltError);
417
415
}
418
416
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))) {
421
419
atomicMin(&zee[OFFSET_4(zee, intSample, 0, intSoutheastY, intSoutheastX)], fltError);
422
420
}
423
421
@@ -554,31 +552,31 @@ def render_pointcloud(tenInput, tenData, intWidth, intHeight, fltFocal, fltBasel
554
552
float fltSouthwest = (intNortheastX - fltOutputX) * (fltOutputY - intNortheastY);
555
553
float fltSoutheast = (fltOutputX - intNorthwestX) * (fltOutputY - intNorthwestY);
556
554
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))) {
558
556
if (fltError <= VALUE_4(zee, intSample, 0, intNorthwestY, intNorthwestX) + 1.0) {
559
557
for (int intData = 0; intData < SIZE_1(data); intData += 1) {
560
558
atomicAdd(&output[OFFSET_4(output, intSample, intData, intNorthwestY, intNorthwestX)], VALUE_3(data, intSample, intData, intPoint) * fltNorthwest);
561
559
}
562
560
}
563
561
}
564
562
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))) {
566
564
if (fltError <= VALUE_4(zee, intSample, 0, intNortheastY, intNortheastX) + 1.0) {
567
565
for (int intData = 0; intData < SIZE_1(data); intData += 1) {
568
566
atomicAdd(&output[OFFSET_4(output, intSample, intData, intNortheastY, intNortheastX)], VALUE_3(data, intSample, intData, intPoint) * fltNortheast);
569
567
}
570
568
}
571
569
}
572
570
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))) {
574
572
if (fltError <= VALUE_4(zee, intSample, 0, intSouthwestY, intSouthwestX) + 1.0) {
575
573
for (int intData = 0; intData < SIZE_1(data); intData += 1) {
576
574
atomicAdd(&output[OFFSET_4(output, intSample, intData, intSouthwestY, intSouthwestX)], VALUE_3(data, intSample, intData, intPoint) * fltSouthwest);
577
575
}
578
576
}
579
577
}
580
578
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))) {
582
580
if (fltError <= VALUE_4(zee, intSample, 0, intSoutheastY, intSoutheastX) + 1.0) {
583
581
for (int intData = 0; intData < SIZE_1(data); intData += 1) {
584
582
atomicAdd(&output[OFFSET_4(output, intSample, intData, intSoutheastY, intSoutheastX)], VALUE_3(data, intSample, intData, intPoint) * fltSoutheast);
0 commit comments