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

Fix/interarea #10

Merged
merged 2 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ python test_dataset.py --gpu 0 --model_path pretrained_model_path --test_img_dir
Dataset|MAE|MSE
-|-|-
sha|69.35|104.4
shb|8.81|15.5
shb|8.58|14.87
qrnf|tbd|tbd

Anyone interested in implementing crowd counting models is welcomed to contact me.
8 changes: 5 additions & 3 deletions dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ def load_data(img_path, ratio, aug, index, kernel_path='maps_adaptive_kernel'):
img = img.convert('L').convert('RGB') # convert to grayscale on 3 channels
count = target.sum()
if ratio>1:
target = cv2.resize(target, (int(target.shape[1]/ratio),int(target.shape[0]/ratio)), interpolation=cv2.INTER_CUBIC) * (ratio**2)

ratio_rounded = int(target.shape[0]) * int(target.shape[1]) / (int(target.shape[1] / ratio) * int(target.shape[0] / ratio))
# INTER_AREA interpolation leads to the smallest error after resizing the target
target = cv2.resize(target, (int(target.shape[1]/ratio),int(target.shape[0]/ratio)), interpolation=cv2.INTER_AREA) * ratio_rounded

return img, target, count


Expand All @@ -71,4 +73,4 @@ def __getitem__(self, index):
img = self.transform(img)
return img, target, count
def __len__(self):
return self.nsamples
return self.nsamples