CSRNet-pytorch icon indicating copy to clipboard operation
CSRNet-pytorch copied to clipboard

MAE of Part_A

Open WangyiNTU opened this issue 7 years ago • 27 comments

Thanks for your Pytorch implementation! I have run the code on the Part_A of ShanghaiTect dataset. In the testing, I can obtain 73.26 MAE for this data. So, how can I reach the 66.4 MAE as mentioned in the readme? Or, this reimplementation is unfinished for now. Thanks!

WangyiNTU avatar Jul 23 '18 13:07 WangyiNTU

Have you trained the model yourself? I'll upload the pretrained model ASAP.

leeyeehoo avatar Jul 26 '18 12:07 leeyeehoo

@leeyeehoo Yes, the final results are improved to 69 MAE, when I use your code without any change. And, I found the data augmentation is disabled in the image.py as follow. It will influence the final results? The previous obtained 73.26 MAE comes from my change (that is, 'if False' is changed to 'if train'). ` if False: crop_size = (img.size[0]/2,img.size[1]/2) if random.randint(0,9)<= -1:

        dx = int(random.randint(0,1)*img.size[0]*1./2)
        dy = int(random.randint(0,1)*img.size[1]*1./2)
    else:
        dx = int(random.random()*img.size[0]*1./2)
        dy = int(random.random()*img.size[1]*1./2)
    
    
    
    img = img.crop((dx,dy,crop_size[0]+dx,crop_size[1]+dy))
    target = target[dy:crop_size[1]+dy,dx:crop_size[0]+dx]
    
    
    
    
    if random.random()>0.8:
        target = np.fliplr(target)
        img = img.transpose(Image.FLIP_LEFT_RIGHT)`

Thanks!

WangyiNTU avatar Jul 27 '18 10:07 WangyiNTU

same question, why the data augmentation is disabled?

grantlj avatar Jul 27 '18 17:07 grantlj

Because we found out that by using the original image without cropping could reach better results. And by using the same cropping method, the results are slightly better in Caffe (mentioned in paper) than PyTorch (you said 73.26).

leeyeehoo avatar Jul 28 '18 02:07 leeyeehoo

OK, I see. Thanks a lot!

WangyiNTU avatar Jul 30 '18 08:07 WangyiNTU

I have used val to test partA, but the mae is very high 0 1039.234375 1 3270.0751953125 2 4630.0849609375 3 7451.38427734375 4 13182.578125 5 14520.990844726562 6 20020.381469726562 7 34471.97229003906 8 36625.15148925781 9 41896.54553222656 10 51193.14318847656 11 51800.69665527344 12 52128.655670166016 13 52754.70217895508 14 55443.40872192383 15 56253.32388305664 16 60179.312408447266 17 60813.217376708984 18 63668.902923583984 19 66381.42611694336 20 69399.40219116211 21 71583.58383178711 22 78590.99594116211 23 82238.25765991211 24 83930.38412475586 25 91782.86410522461

liuleiBUAA avatar Sep 26 '18 01:09 liuleiBUAA

@liuleiBUAA In the val.ipynb, you should change it as follow:

# img = 255.0 * F.to_tensor(Image.open(img_paths[i]).convert('RGB'))
# img[0,:,:]=img[0,:,:]-92.8207477031
# img[1,:,:]=img[1,:,:]-95.2757037428
# img[2,:,:]=img[2,:,:]-104.877445883
# img = img.cuda()
img = transform(Image.open(img_paths[i]).convert('RGB')).cuda()

WangyiNTU avatar Sep 27 '18 06:09 WangyiNTU

Thank you@ WangyiNTU Have you trained the model? How many epoch have you used to train the model in part A and part B

liuleiBUAA avatar Sep 27 '18 08:09 liuleiBUAA

@liuleiBUAA python train.py part_A_train.json part_A_test.json 0 0 is OK for me. run make_dataset.ipynb first.

WangyiNTU avatar Sep 28 '18 11:09 WangyiNTU

I train the model, but loss is nan, do you have the same problem Epoch: [0][300/1200] Time 0.415 (0.414) Data 0.018 (0.020) Loss nan (nan)

liuleiBUAA avatar Sep 29 '18 09:09 liuleiBUAA

@liuleiBUAA I didn't have this problem.

WangyiNTU avatar Sep 29 '18 13:09 WangyiNTU

@WangyiNTU Thank you for your help, I trained from the start, the loss is nan, I will try to solve this problem

liuleiBUAA avatar Sep 30 '18 01:09 liuleiBUAA

@WangyiNTU I change the model.py in class CSRNet(nn.Module): def init(self, load_weights=False): to class CSRNet(nn.Module): def init(self, load_weights=True): The model can convergence, however, I cannot get the MAE of 68 in partA and 10.6 in partB do you change the code like this?

liuleiBUAA avatar Oct 03 '18 01:10 liuleiBUAA

@liuleiBUAA load_weights=True doesn't use pretrained VGG and initialize parameters as a Gaussian distribution. I run in load_weights=False setting and get 69 MAE on Part A.

WangyiNTU avatar Oct 03 '18 02:10 WangyiNTU

@WangyiNTU Thank you. Can I see your model.py for part of class CSRnet? and how many epoch have you train the model?

liuleiBUAA avatar Oct 03 '18 02:10 liuleiBUAA

If I set load_weights=False, the loss is very high and will be nan

liuleiBUAA avatar Oct 03 '18 02:10 liuleiBUAA

Have you trained the model yourself? I'll upload the pretrained model ASAP.

Could you tell me where is your pretained model ASAP,I can not find it

Thanks for your Pytorch implementation! I have run the code on the Part_A of ShanghaiTect dataset. In the testing, I can obtain 73.26 MAE for this data. So, how can I reach the 66.4 MAE as mentioned in the readme? Or, this reimplementation is unfinished for now. Thanks!

Could you tell me where is the pretain parameters of CSRnet? Or you get the MAE 73.26 by using your own training parameters?

jiehaohuang avatar Oct 08 '18 10:10 jiehaohuang

@jiehaohuang Here, ShanghaiA MAE: 66.4 Google Drive ShanghaiB MAE: 10.6 Google Drive

WangyiNTU avatar Oct 11 '18 06:10 WangyiNTU

@WangyiNTU Hi, I use your parameters, and get 66.622 for ShanghaiA, 11.98 for ShanghaiB. Does this is normal error range?

LaiPiXiong avatar Nov 23 '18 07:11 LaiPiXiong

@WangyiNTU Hi, I use your parameters, and get 66.622 for ShanghaiA, 11.98 for ShanghaiB. Does this is normal error range?

The parameters is provided by author. Your results are normal I suppose.

WangyiNTU avatar Nov 25 '18 06:11 WangyiNTU

@WangyiNTU Thanks, I see.

LaiPiXiong avatar Nov 25 '18 13:11 LaiPiXiong

@liuleiBUAA python train.py part_A_train.json part_A_test.json 0 0 is OK for me. run make_dataset.ipynb first.

Hi, I have a question about the path of validation, in your format, could I understand that you regard the test set as the validation set? And there are two json file related to validation set in author's release, I'm confused...

ysyyo avatar Feb 19 '19 02:02 ysyyo

@leeyeehoo I'm facing with a problem when training TRANCOS from scratch, can you provide pretrained model of TRANCOS dataset,

ThanhNhann avatar Mar 30 '20 05:03 ThanhNhann

Hi, I have deleted the pretrained model, you can use CSRnet frist

------------------ 原始邮件 ------------------ 发件人: "Nguyễn Thành Nhân"<[email protected]>; 发送时间: 2020年3月30日(星期一) 中午1:08 收件人: "leeyeehoo/CSRNet-pytorch"<[email protected]>; 抄送: "刘雷"<[email protected]>;"Mention"<[email protected]>; 主题: Re: [leeyeehoo/CSRNet-pytorch] MAE of Part_A (#8)

@leeyeehoo I'm facing with a problem when training TRANCOS from scratch, can you provide pretrained model of TRANCOS dataset,

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

liuleiBUAA avatar Mar 30 '20 05:03 liuleiBUAA

@leeyeehoo @liuleiBUAA can you explain your comment "you can use CSRnet frist", there are 4 metrics to measure (GAME), but I dont know how to concatenate them to have the final result, can you tell me more hint about this ? thanks

ThanhNhann avatar Mar 30 '20 06:03 ThanhNhann

@liuleiBUAA python train.py part_A_train.json part_A_test.json 0 0 is OK for me. run make_dataset.ipynb first.

Hi, I have a question about the path of validation, in your format, could I understand that you regard the test set as the validation set? And there are two json file related to validation set in author's release, I'm confused...

Me too~~

Tongzi-Zhang avatar Apr 03 '24 03:04 Tongzi-Zhang

@liuleiBUAA In the val.ipynb, you should change it as follow:

# img = 255.0 * F.to_tensor(Image.open(img_paths[i]).convert('RGB'))
# img[0,:,:]=img[0,:,:]-92.8207477031
# img[1,:,:]=img[1,:,:]-95.2757037428
# img[2,:,:]=img[2,:,:]-104.877445883
# img = img.cuda()
img = transform(Image.open(img_paths[i]).convert('RGB')).cuda()

Thanks

Tongzi-Zhang avatar Apr 03 '24 09:04 Tongzi-Zhang