PSMNet icon indicating copy to clipboard operation
PSMNet copied to clipboard

an inconsistent indentation in stackhourglass.py

Open BenedictGreen opened this issue 5 years ago • 2 comments

Thanks for your great work. When I use the Test_img.py to get the disparity img, I notice an error in stackhourglass.py at line137

        if self.training:
	cost1 = F.upsample(cost1, [self.maxdisp,left.size()[2],left.size()[3]], mode='trilinear')
	cost2 = F.upsample(cost2, [self.maxdisp,left.size()[2],left.size()[3]], mode='trilinear')

	cost1 = torch.squeeze(cost1,1)
	pred1 = F.softmax(cost1,dim=1)
	pred1 = disparityregression(self.maxdisp)(pred1)

	cost2 = torch.squeeze(cost2,1)
	pred2 = F.softmax(cost2,dim=1)
	pred2 = disparityregression(self.maxdisp)(pred2)

        cost3 = F.upsample(cost3, [self.maxdisp,left.size()[2],left.size()[3]], mode='trilinear')
        cost3 = torch.squeeze(cost3,1)
        pred3 = F.softmax(cost3,dim=1)
	#For your information: This formulation 'softmax(c)' learned "similarity" 
	#while 'softmax(-c)' learned 'matching cost' as mentioned in the paper.
	#However, 'c' or '-c' do not affect the performance because feature-based cost volume provided flexibility.
        pred3 = disparityregression(self.maxdisp)(pred3)

it seem that previous line using space,this line uses tabs. I got an error :"local variable 'pred3' referenced before assignment". I think that inconsistent indentation cause the problem. Am I wrong or how could I improve it?

Thanks again!

BenedictGreen avatar Nov 16 '20 14:11 BenedictGreen

@BenedictGreen Hi, you can use spaces to replace tabs for these indentation. If it is not working, you could past your error messages.

JiaRenChang avatar Nov 17 '20 01:11 JiaRenChang

@BenedictGreen Hi, you can use spaces to replace tabs for these indentation. If it is not working, you could past your error messages.

@JiaRenChang Looks like you mix 2 tabs with 1 tab + 4 space, where your tab, surprisingly, turns out to be 8 spaces. Do you want to fix this? It's not something hard. Or I can PR u. I have fixed it now.

@BenedictGreen Replace all tabs with 8 spaces, where it apply. This can solve your issue.

Cli98 avatar Dec 01 '20 09:12 Cli98