ZhihengCV / Bayesian-Crowd-Counting

Official Implement of ICCV 2019 oral paper Bayesian Loss for Crowd Count Estimation with Point Supervision
330 stars 84 forks source link

Preprocessing scenes with < 4 people gives out of range error #18

Closed cjgalvin closed 4 years ago

cjgalvin commented 4 years ago

I am processing the GCC synthetic dataset (GTAV scenes) for training on the Bayesian Loss model. When there are < 4 people in a scene, the find_dis function in the preprocess_dataset.py gives an out of range error. The specific line throwing the error is the following:

Line 39: dis = np.mean(np.partition(dis, 3, axis=1)[:, 1:4], axis=1, keepdims=True)

When there are < 4 people, the kth=3 argument in the np.partition function leads to the error. While changing the kth argument to a smaller number (for example, 0) will eliminate the error, I am curious about the logic for using the partition function? And why only average 3 columns (columns 1, 2 and 3) from the partitioned array?

Thank you, Casey

rongliangzi commented 4 years ago

Hi! I'd like to share my understanding! average 3 columns (columns 1, 2 and 3) is to calculate the average distance of one head to three nearest heads of it (this is proposed by MCNN CVPR-2016 to estimate the delta parameter when generating ground truth density maps).

np.partition is used to select the nearest three distances. Since the nearest distance is 0(itself), the column is set to [1:4].

cjgalvin commented 4 years ago

@rongliangzi Thank you for your comment. It was very helpful.