Pirazh / Vehicle_Key_Point_Orientation_Estimation

This is the repository for Vehicle Key-Point and Orientation Estimation
82 stars 18 forks source link

stage2 #3

Closed cdy0917 closed 4 years ago

cdy0917 commented 4 years ago

Hi sir, train stage2 appear : AttributeError:'KeyPointModel' object has no attribute ‘module’

Pirazh commented 4 years ago

Hi, can you please provide the full trace back?

cdy0917 commented 4 years ago

Hi, can you please provide the full trace back?

thank you sir, train stage2 running:python /media/cdy/cdy/stage2/Vehicle_Key_Point_Orientation_Estimation-master/main.py --phase train --use_case stage2 --mGPU --lr 0.0001 --epochs 15 --stage1_ckpt /home/cdy/stage1/2019-11-22-12/best_checkpoint.pth.tar

Problems: Traceback (most recent call last): File "/media/cdy/cdy/stage2/Vehicle_Key_Point_Orientation_Estimation-master/main.py", line 86, in main(args)

File "/media/cdy/cdy/stage2/Vehicle_Key_Point_Orientation_Estimation-master/main.py", line 42, in main train.train(args, net)

File "/media/cdy/cdy/stage2/Vehicle_Key_Point_Orientation_Estimation-master/tools/train.py", line 118, in train params = net.module.refinement.parameters() if args.mGPU else net.refinement.parameters()

File "/home/cdy/anaconda3/envs/pytorch1.3/lib/python2.7/site-packages/torch/nn/modules/module.py", line 585, in getattr type(self).name, name)) AttributeError: 'KeyPointModel' object has no attribute 'module'

Pirazh commented 4 years ago

How many GPUs are you using? it looks like the module wrapper which is used in case you have multiple GPUs and you want to use all of them is not there, so since you are passing in --mGPU flag, no t more than one GPU is visible to the code i guess.

cdy0917 commented 4 years ago

How many GPUs are you using? it looks like the module wrapper which is used in case you have multiple GPUs and you want to use all of them is not there, so since you are passing in --mGPU flag, not more than one GPU is visible to the code i guess. thank you sir, I use a single GPU. I tried to modify based on your suggestions, but the result is the same.and I checked the mGPU is default = False in main.py file; in addition, In KP_Orientation_Net.py, line 99 self.refinement = FineRegressor () After I inserted print () (Insert situation is: class KeyPoint(nn.Module):

""" End-to-End Key-Point Regression models """

def init(self):

    super(KeyPointModel, self).__init__()
    self.coarse_estimator = CoarseRegressor()
    self.refinement = FineRegressor()
    print()
def forward(self, x1, x2):
...

)

the result is:
Total number of Parameters = 21252067

Total number of trainable Parameters = 6238182

KeyPointModel(
(coarse_estimator): CoarseRegressor(

(A1): Sequential(

(0): Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))

(1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU(inplace=True)

(3): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))

(4): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(5): ReLU(inplace=True)

(6): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False) )

(A2): Sequential(

(0): Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))

(1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU(inplace=True)

(3): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))

(4): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(5): ReLU(inplace=True) (6): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False) )

(A3): Sequential(

(0): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))

(1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU(inplace=True)

(3): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))

(4): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(5): ReLU(inplace=True)

(6): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))

(7): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(8): ReLU(inplace=True)

(9): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False) )

(A4): Sequential(

(0): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))

(1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU(inplace=True)

(3): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))

(4): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(5): ReLU(inplace=True)

(6): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))

(7): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(8): ReLU(inplace=True)

(9): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False) )

(A5): Sequential(

(0): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))

(1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU(inplace=True)

(3): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))

(4): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(5): ReLU(inplace=True)

(6): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))

(7): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(8): ReLU(inplace=True)

(9): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False) )

(A6): Sequential(

(0): Conv2d(512, 512, kernel_size=(1, 1), stride=(1, 1))

(1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU()

)

(A6to7): Sequential(

(0): Conv2d(512, 21, kernel_size=(1, 1), stride=(1, 1))

(1): BatchNorm2d(21, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU()

)

(A3to7): Sequential(

(0): Conv2d(256, 21, kernel_size=(1, 1), stride=(1, 1))

(1): BatchNorm2d(21, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU()

)

(A4to7): Sequential(

(0): Conv2d(512, 21, kernel_size=(1, 1), stride=(1, 1))

(1): BatchNorm2d(21, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU()

)

(Up): Upsample(scale_factor=2.0, mode=bilinear)


)

(refinement): FineRegressor(

(Normalize): Softmax(dim=2)

(MaxPool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)

(L1): Sequential(

(0): Conv2d(24, 64, kernel_size=(7, 7), stride=(1, 1))

(1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU()

)

(HR1): Sequential(

(0): Conv2d(64, 64, kernel_size=(7, 7), stride=(1, 1))

(1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU()

(3): Conv2d(64, 128, kernel_size=(5, 5), stride=(1, 1))

(4): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(5): ReLU()

(6): Conv2d(128, 256, kernel_size=(1, 1), stride=(1, 1))

(7): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(8): ReLU()

(9): ConvTranspose2d(256, 128, kernel_size=(5, 5), stride=(1, 1))

(10): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(11): ReLU()

(12): ConvTranspose2d(128, 64, kernel_size=(7, 7), stride=(1, 1))

(13): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(14): ReLU()

)

(res1): Sequential(

(0): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1))

(1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU()

)

(L2): Sequential(

(0): ConvTranspose2d(64, 21, kernel_size=(7, 7), stride=(1, 1))

(1): BatchNorm2d(21, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU()

(3): Conv2d(21, 64, kernel_size=(7, 7), stride=(1, 1))

(4): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(5): ReLU()

)

(L3): Sequential(

(0): Conv2d(64, 64, kernel_size=(7, 7), stride=(1, 1))

(1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU()

(3): Conv2d(64, 128, kernel_size=(5, 5), stride=(1, 1))

(4): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(5): ReLU()

(6): Conv2d(128, 256, kernel_size=(1, 1), stride=(1, 1))

(7): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(8): ReLU()

)

(res2): Sequential(

(0): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1))

(1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU()

)

(L4): Sequential(

(0): ConvTranspose2d(256, 128, kernel_size=(5, 5), stride=(1, 1))

(1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU()

(3): ConvTranspose2d(128, 64, kernel_size=(7, 7), stride=(1, 1))

(4): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(5): ReLU()

)

(L5): Sequential(

(0): ConvTranspose2d(64, 21, kernel_size=(7, 7), stride=(1, 1))

(1): BatchNorm2d(21, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU()

)

(pose_branch1): Sequential(

(0): Conv2d(256, 128, kernel_size=(7, 7), stride=(1, 1))

(1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU()

(3): Conv2d(128, 64, kernel_size=(7, 7), stride=(1, 1))

(4): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(5): ReLU()

)

(pose_branch2): Sequential(

(0): Conv2d(64, 32, kernel_size=(7, 7), stride=(1, 1))

(1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)

(2): ReLU()

)

(FC): Sequential(

(0): Linear(in_features=2048, out_features=256, bias=True)

(1): Dropout(p=0.5, inplace=False)

(2): Linear(in_features=256, out_features=8, bias=True)

)


)
)
Traceback (most recent call last):
File "/media/cdy/cdy/stage2/Vehicle_Key_Point_Orientation_Estimation-master/main.py", line 86, in

main(args)

File "/media/cdy/cdy/stage2/Vehicle_Key_Point_Orientation_Estimation-master/main.py", line 42, in main

train.train(args, net)

File "/media/cdy/cdy/stage2/Vehicle_Key_Point_Orientation_Estimation-master/tools/train.py", line 118, in train

params = net.module.refinement.parameters() if args.mGPU else net.refinement.parameters()


File "/home/cdy/anaconda3/envs/pyotrch1.3/lib/python2.7/site-packages/torch/nn/modules/module.py", line 585, in **getattr**
type(self).**name**, name))
AttributeError: 'KeyPointModel' object has no attribute 'module'
Pirazh commented 4 years ago

I have updated train.py script, please download it and check if it works.

cdy0917 commented 4 years ago

I have updated train.py script, please download it and check if it works. thank you sir,It runs successfully! Thanks for your patience, I made similar changes elsewhere in train.py, and it's running, thanks for your help!

Pirazh commented 4 years ago

You are welcome, now that the issue is resolved I am closing it.