IIM
IIM copied to clipboard
How to visualize other datasets test set pictures?
Thanks for the author's impressive work! Question 1: How to visualize test set pictures for SHHA, SHHB, UCF-QNRF, FDST?
Question 2: The link (DATA.md) is broken, could you please update the link, especially SHHA and SHHB, thanks.
A1: You can generate the prediction results for other students, and then modify the vis4val .py
to generate the visual results.
A2: We have created another download link for the Shanghai Tech Dataset.
Thank you for your reply in your busy schedule. May I ask you three questions?
Question 1:
The txt files of the test set SHHB_VGG16_FPN_test.txt and SHHB_HR_Net_test.txt are used in the test set of SHHB provided by the author. The code is as follows:
dataset = 'SHHB'
dataRoot = '/Documents/Datasets/IIM/ProcessedData/' + dataset
gt_file = dataRoot + '/test_gt_loc.txt'
img_path = ori_data = dataRoot + '/images'
flagError = False
id_std = [i for i in range(401,716,1)]
# id_std[59] = 3098
exp_name = './saved_exp_results/SHHB_vis_results'
pred_file = '/Documents/Datasets/IIM/PredictionsOnTestSet/SHHB_VGG16_FPN_test.txt'
Prompt me error :
401
Traceback (most recent call last):
File "vis4val.py", line 129, in <module>
main()
File "vis4val.py", line 125, in main
cv2.imwrite(exp_name+'/'+str(i_sample)+ '_pre_' + str(pre)[0:6] + '_rec_' + str(rec)[0:6] + '.jpg', img)
cv2.error: OpenCV(3.4.11) /tmp/pip-req-build-1cb5e5yp/opencv/modules/imgcodecs/src/loadsave.cpp:759: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'
The same error occurs in the same dataset SHHA
as above. Could you please ask how to adjust the code?
Question2:
JHU's test set image order is random, id_std=?
. Could you please ask how to adjust the code? The code is as follows:
dataset = 'JHU'
dataRoot = '/Documents/Datasets/IIM/ProcessedData/' + dataset
gt_file = dataRoot + '/test_gt_loc.txt'
img_path = ori_data = dataRoot + '/images'
exp_name = '/Experiments/IIM/IIM_HR/saved_exp_results/VGG_JHU_vis_results'
pred_file = '/Documents/Datasets/IIM/PredictionsOnTestSet/JHU_VGG16_FPN_test.txt'
flagError = False
id_std = [i for i in range(2409,4380,1)]
Prompt me error :
2409
Traceback (most recent call last):
File "vis4val.py", line 129, in <module>
main()
File "vis4val.py", line 125, in main
cv2.imwrite(exp_name+'/'+str(i_sample)+ '_pre_' + str(pre)[0:6] + '_rec_' + str(rec)[0:6] + '.jpg', img)
cv2.error: OpenCV(3.4.11) /tmp/pip-req-build-1cb5e5yp/opencv/modules/imgcodecs/src/loadsave.cpp:759: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'
KeyError: 2410
And what is id_std=?
for FDST?
dataset = 'FDST'
dataRoot = '/bulk/wenzhe/Documents/Datasets/IIM/ProcessedData/' + dataset
gt_file = dataRoot + '/test_gt_loc.txt'
img_path = ori_data = dataRoot + '/images'
exp_name = '/Experiments/IIM/IIM_HR/saved_exp_results/VGG_FDST_vis_results'
pred_file = '/Documents/Datasets/IIM/PredictionsOnTestSet/FDST_HR_Net_test.txt'
flagError = False
id_std = [i for i in range(10_001,99_150,1)]
Prompt me error, import data 10001 instead of 10001 , Could you please tell me how to modify the code?
10001
Traceback (most recent call last):
File "vis4val.py", line 148, in <module>
main()
File "vis4val.py", line 79, in main
if gt_data[i_sample]['num'] ==0 and pred_data[i_sample]['num'] !=0:
Question3:
When the training set is set to NWPU, an error will be reported. Could you please tell me what caused it and how to modify the code? Thanks.
====================
0%| | 0/500 [00:00<?, ?it/s]Traceback (most recent call last):
File "train.py", line 31, in <module>
cc_trainer.forward()
File "/bulk/wenzhe/Experiments/IIM/IIM_HR/trainer.py", line 72, in forward
self.validate()
File "/bulk/wenzhe/Experiments/IIM/IIM_HR/trainer.py", line 183, in validate
assert img.size()[2:] == dot_map.size()[2:]
AssertionError
Looking forward to your reply. Thank you very much for your kind help.
Q1: you can try to fix it by installing the opencv-python
package, here is my opencv version:
-
opencv-contrib-python==4.2.0.34
-
opencv-python==4.5.1.48
Q2: One way to generate the id list for JHU is to read the txt list of JHU test set, like bellow
2409 0844 0400 0700 1872 2985 2873 1563 3987 3603 3551 0651 3255 3148 2946 ....
We here only provide the code for the visualization of several typical datasets. This code would be failed when the data format is not the same as the code targeted. For FDST's visualization, you can figure it out after you know how the code works.
Q3: Have you generated the dot map correctly? it is recommended to debug step by step and find why your image size is not the same as the dot_map.
Thanks your patient explanation extremely !
It was replaced according to your instructions opencv-contrib-python
and
opencv-python
, but the error cv2.error: OpenCV(4.5.4)
still exists.
After verification, it is found that the file name may be the reason. For the SHHB data set, the same error is displayed when 'id_std = [I for I in range(401,716,1)]'. However, renaming the picture 0401.jpg
to 401.jpg
, and replacing all 0401
in the .txt
with 401 only works for one 401.jpg
picture.
So is there any way to run this code besides changing the way of renaming?
I replace 401
with 0401
, and replaced the code with the following:
id_std = [i for i in range(0401,0716,1)]
or
id_std = [i for i in range(''0401'',''0716'',1)]
The error is:
File "vis4val.py", line 54
id_std = [i for i in range(0401,0716,1)]
^
SyntaxError: invalid token
and
File "vis4val.py", line 54
id_std = [i for i in range(''0401'',''0716'',1)]
^
SyntaxError: invalid token
Could you please tell me what caused it and how to modify id_std = ?
or modify other code ? Thanks.
Thank you for writing back to me from your busy schedule.
id_std
is an id list of the pictures that also have been saved as keys in test_gt_loc.txt
, id list is set in advance to index the prediction result and the ground truth result for each image from the gt_loc.txt and pred_loc.txt.
[i for i in range(''0401'',''0716'',1)] or id_std = [i for i in range(0401,0716,1)] are the wrong usages cause you can't range between two strings. They must be integer.
Thank you very much for your reply!
Thanks your patient explanation extremely ! It was replaced according to your instructions
opencv-contrib-python
andopencv-python
, but the errorcv2.error: OpenCV(4.5.4)
still exists. After verification, it is found that the file name may be the reason. For the SHHB data set, the same error is displayed when 'id_std = [I for I in range(401,716,1)]'. However, renaming the picture0401.jpg
to401.jpg
, and replacing all0401
in the.txt
with 401 only works for one401.jpg
picture. So is there any way to run this code besides changing the way of renaming?I replace
401
with0401
, and replaced the code with the following:id_std = [i for i in range(0401,0716,1)]
or
id_std = [i for i in range(''0401'',''0716'',1)]
The error is:
File "vis4val.py", line 54 id_std = [i for i in range(0401,0716,1)] ^ SyntaxError: invalid token
and
File "vis4val.py", line 54 id_std = [i for i in range(''0401'',''0716'',1)] ^ SyntaxError: invalid token
Could you please tell me what caused it and how to modify
id_std = ?
or modify other code ? Thanks.Thank you for writing back to me from your busy schedule.
About Q1, you can try fix this code. img = cv2.imread(img_path + '/' + str(i_sample).zfill(4) + '.jpg')