Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I predict with a picture of myself? #6

Open
yds5817 opened this issue Jul 9, 2019 · 15 comments
Open

How do I predict with a picture of myself? #6

yds5817 opened this issue Jul 9, 2019 · 15 comments

Comments

@yds5817
Copy link

yds5817 commented Jul 9, 2019

No description provided.

@yds5817
Copy link
Author

yds5817 commented Jul 9, 2019

There is no. Mat file in my own picture, so I removed the second path in 'paths', but there was an error next!
‘’‘
Traceback (most recent call last):
File "main.py", line 1098, in
train()
File "main.py", line 1019, in train
test_batch_size=4)
File "/data/shareJ/YDS/lsc-cnn-master/data_reader.py", line 200, in create_dataset_files
self._dump_all_test_images(set_name)
File "/data/shareJ/YDS/lsc-cnn-master/data_reader.py", line 837, in _dump_all_test_images
crops = self._get_one_image_test_crops(data)
File "/data/shareJ/YDS/lsc-cnn-master/data_reader.py", line 555, in _get_one_image_test_crops
<= data[0].shape[WIDTH_IDX] and
IndexError: tuple index out of range
’‘’

@MounirB
Copy link

MounirB commented Jul 9, 2019

I think that there is not a dedicated script for the prediction task. Can the authors provide us a script that accomplishes this task or at least give us some instructions to create it and contribute to the project ?

@pvskand
Copy link
Contributor

pvskand commented Jul 12, 2019

Hello,
I'm in the process of adding this feature, but for the time being, you can keep the .mat file as is and put your image in the images folder and dump the dataset and then test according to the instructions given in the README.md.
Let me know if you run into problems with this hack.

@vlad3996
Copy link

You can try to use my fork :
https://github.com/vlad3996/lsc-cnn

@learnermaxRL
Copy link

@vlad3996 not working.can you tell me what weights and what needs to be done,i get fllowing error -

RuntimeError: Error(s) in loading state_dict for LSCCNN: Missing key(s) in state_dict: "conv1_1.weight", "conv1_1.bias", "conv1_2.weight", "conv1_2.bias", "conv2_1.weight", "conv2_1.bias", "conv2_2.weight", "conv2_2.bias", "conv3_1.weight", "conv3_1.bias", "conv3_2.weight", "conv3_2.bias", "conv3_3.weight", "conv3_3.bias", "conv4_1.weight", "conv4_1.bias", "conv4_2.weight", "conv4_2.bias", "conv4_3.weight", "conv4_3.bias", "conv5_1.weight", "conv5_1.bias", "conv5_2.weight", "conv5_2.bias", "conv5_3.weight", "conv5_3.bias", "convA_1.weight", "convA_1.bias", "convA_2.weight", "convA_2.bias", "convA_3.weight", "convA_3.bias", "convA_4.weight", "convA_4.bias", "convA_5.weight", "convA_5.bias", "convB_1.weight", "convB_1.bias", "convB_2.weight", "convB_2.bias", "convB_3.weight", "convB_3.bias", "convB_4.weight", "convB_4.bias", "convB_5.weight", "convB_5.bias", "convC_1.weight", "convC_1.bias", "convC_2.weight", "convC_2.bias", "convC_3.weight", "convC_3.bias", "convC_4.weight", "convC_4.bias", "convC_5.weight", "convC_5.bias", "convD_1.weight", "convD_1.bias", "convD_2.weight", "convD_2.bias", "convD_3.weight", "convD_3.bias", "convD_4.weight", "convD_4.bias", "convD_5.weight", "convD_5.bias", "conv_before_transpose_1.weight", "conv_before_transpose_1.bias", "transpose_1.weight", "transpose_1.bias", "conv_after_transpose_1_1.weight", "conv_after_transpose_1_1.bias", "transpose_2.weight", "transpose_2.bias", "conv_after_transpose_2_1.weight", "conv_after_transpose_2_1.bias", "transpose_3.weight", "transpose_3.bias", "conv_after_transpose_3_1.weight", "conv_after_transpose_3_1.bias", "transpose_4_1_a.weight", "transpose_4_1_a.bias", "transpose_4_1_b.weight", "transpose_4_1_b.bias", "conv_after_transpose_4_1.weight", "conv_after_transpose_4_1.bias", "transpose_4_2.weight", "transpose_4_2.bias", "conv_after_transpose_4_2.weight", "conv_after_transpose_4_2.bias", "transpose_4_3.weight", "transpose_4_3.bias", "conv_after_transpose_4_3.weight", "conv_after_transpose_4_3.bias", "conv_middle_1.weight", "conv_middle_1.bias", "conv_middle_2.weight", "conv_middle_2.bias", "conv_middle_3.weight", "conv_middle_3.bias", "conv_mid_4.weight", "conv_mid_4.bias", "conv_lowest_1.weight", "conv_lowest_1.bias", "conv_lowest_2.weight", "conv_lowest_2.bias", "conv_lowest_3.weight", "conv_lowest_3.bias", "conv_lowest_4.weight", "conv_lowest_4.bias", "conv_scale1_1.weight", "conv_scale1_1.bias", "conv_scale1_2.weight", "conv_scale1_2.bias", "conv_scale1_3.weight", "conv_scale1_3.bias". Unexpected key(s) in state_dict: "epoch", "state_dict", "optimizer".

@learnermaxRL
Copy link

after downlaoding wieghts mentioned in your readme -

out = self.forward(torch.from_numpy(image.transpose((2, 0, 1)).astype(np.float32)).unsqueeze(0).cuda()) File "/home/jbasmsdsdai/Downloads/lsc-cnn-master/model.py", line 140, in forward sub1_concat = torch.cat((sub1_out_conv1, sub1_after_transpose_1), dim=1) RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 74 and 75 in dimension 2 at /opt/conda/conda-bld/pytorch_1556653215914/work/aten/src/THC/generic/THCTensorMath.cu:71

@vlad3996
Copy link

@learnermaxRL the problem is with input image shape : it must be divisible by 16 because author concatenate feature maps from 3rd pooling layer and upsampled by nn.ConvTranspose2d maps from 4th pooling layer, which can not match by shape.

@usamahjundia
Copy link

If people are interested, i wrote some code to port the existing .pth weights into a keras version of the model, although it doesnt support batch predictions for now, only one, and i used the same NMS approach used in this repository, but if your goal is to just do prediction, it can be used

Example of using the detection from the model is also supplied

@zhoujoey
Copy link

@learnermaxRL the problem is with input image shape : it must be divisible by 16 because author concatenate feature maps from 3rd pooling layer and upsampled by nn.ConvTranspose2d maps from 4th pooling layer, which can not match by shape.

You can try to use my fork :
https://github.com/vlad3996/lsc-cnn

How to train other dataset in you fork?

@AniketVelhankar
Copy link

You can try to use my fork :
https://github.com/vlad3996/lsc-cnn

How do I get the count of people ? Does it return somewhere ?

@usamahjundia
Copy link

You can try to use my fork :
https://github.com/vlad3996/lsc-cnn

How do I get the count of people ? Does it return somewhere ?

it is easily achievable by getting the length of the resulting array of detections

@knightyxp
Copy link

You can try to use my fork :
https://github.com/vlad3996/lsc-cnn

image
this is my test result ,why

@kaamlaS
Copy link

kaamlaS commented Aug 16, 2022

@vlad3996 not working.can you tell me what weights and what needs to be done,i get fllowing error -

RuntimeError: Error(s) in loading state_dict for LSCCNN: Missing key(s) in state_dict: "conv1_1.weight", "conv1_1.bias", "conv1_2.weight", "conv1_2.bias", "conv2_1.weight", "conv2_1.bias", "conv2_2.weight", "conv2_2.bias", "conv3_1.weight", "conv3_1.bias", "conv3_2.weight", "conv3_2.bias", "conv3_3.weight", "conv3_3.bias", "conv4_1.weight", "conv4_1.bias", "conv4_2.weight", "conv4_2.bias", "conv4_3.weight", "conv4_3.bias", "conv5_1.weight", "conv5_1.bias", "conv5_2.weight", "conv5_2.bias", "conv5_3.weight", "conv5_3.bias", "convA_1.weight", "convA_1.bias", "convA_2.weight", "convA_2.bias", "convA_3.weight", "convA_3.bias", "convA_4.weight", "convA_4.bias", "convA_5.weight", "convA_5.bias", "convB_1.weight", "convB_1.bias", "convB_2.weight", "convB_2.bias", "convB_3.weight", "convB_3.bias", "convB_4.weight", "convB_4.bias", "convB_5.weight", "convB_5.bias", "convC_1.weight", "convC_1.bias", "convC_2.weight", "convC_2.bias", "convC_3.weight", "convC_3.bias", "convC_4.weight", "convC_4.bias", "convC_5.weight", "convC_5.bias", "convD_1.weight", "convD_1.bias", "convD_2.weight", "convD_2.bias", "convD_3.weight", "convD_3.bias", "convD_4.weight", "convD_4.bias", "convD_5.weight", "convD_5.bias", "conv_before_transpose_1.weight", "conv_before_transpose_1.bias", "transpose_1.weight", "transpose_1.bias", "conv_after_transpose_1_1.weight", "conv_after_transpose_1_1.bias", "transpose_2.weight", "transpose_2.bias", "conv_after_transpose_2_1.weight", "conv_after_transpose_2_1.bias", "transpose_3.weight", "transpose_3.bias", "conv_after_transpose_3_1.weight", "conv_after_transpose_3_1.bias", "transpose_4_1_a.weight", "transpose_4_1_a.bias", "transpose_4_1_b.weight", "transpose_4_1_b.bias", "conv_after_transpose_4_1.weight", "conv_after_transpose_4_1.bias", "transpose_4_2.weight", "transpose_4_2.bias", "conv_after_transpose_4_2.weight", "conv_after_transpose_4_2.bias", "transpose_4_3.weight", "transpose_4_3.bias", "conv_after_transpose_4_3.weight", "conv_after_transpose_4_3.bias", "conv_middle_1.weight", "conv_middle_1.bias", "conv_middle_2.weight", "conv_middle_2.bias", "conv_middle_3.weight", "conv_middle_3.bias", "conv_mid_4.weight", "conv_mid_4.bias", "conv_lowest_1.weight", "conv_lowest_1.bias", "conv_lowest_2.weight", "conv_lowest_2.bias", "conv_lowest_3.weight", "conv_lowest_3.bias", "conv_lowest_4.weight", "conv_lowest_4.bias", "conv_scale1_1.weight", "conv_scale1_1.bias", "conv_scale1_2.weight", "conv_scale1_2.bias", "conv_scale1_3.weight", "conv_scale1_3.bias". Unexpected key(s) in state_dict: "epoch", "state_dict", "optimizer".

@learnermaxRL how did you fix the error you were experiencing?

@mic2112
Copy link

mic2112 commented Aug 17, 2022

@kaamlaS add model.load_state_dict(checkpoint['state_dict'], strict=False) to line 107 in model.py

@mic2112
Copy link

mic2112 commented Aug 17, 2022

You can try to use my fork :
https://github.com/vlad3996/lsc-cnn

image this is my test result ,why

@knightyxp Did you manage to get better results from this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests