zhiyuanyou / SAFECount

[WACV 2023] Few-shot Object Counting with Similarity-Aware Feature Enhancement
Other
124 stars 22 forks source link

Query - How to deal with the original image size and examplar scales #19

Closed m-zheng closed 1 year ago

m-zheng commented 1 year ago

Hi, thanks for sharing the source code for your paper.

I am struggling to understand the reason to make the scaled query image size dividable by 16.

https://github.com/zhiyuanyou/SAFECount/blob/318ae8872f960257f22bd6c861414d45829a7260/models/safecount.py#L63-L64

Suppose the examplar scale is 0.8 and the query image size is 520 * 520. Its scaled query image size becomes 409.6 * 409.6. Applying int(409.6) can lead to 409 * 409. Your implementation above will lead to 400 * 400. Can you kindly share the reason behind it?

zhiyuanyou commented 1 year ago

Hi~

We use the feature from _layer_1, layer_2, & layer_3 of resnet18. The features from these 3 layers have the stride of 4, 8, & 16_, respectively.

As stated in the paper, these 3 features need to be resized to the same size, and then concatenated together. The resize operation is done using stride, instead of a given size.

Therefore, if the image size could not be divided by 16, the 3 resized features will have different sizes, thus can not be concatenated together.

m-zheng commented 1 year ago

Thanks for your help. It makes sense now.

Following by that, have you considered using the original image to get features from resnet18 and rescale them afterwards? In other words, have you considered the difference between

  1. resnet18(resize(image))
  2. resize(resnet18(image))
zhiyuanyou commented 1 year ago

Not yet. 

You can do this comparison to see which one is better. 

---Original--- From: "Minghua @.> Date: Sun, Apr 23, 2023 18:31 PM To: @.>; Cc: "You @.>;"State @.>; Subject: Re: [zhiyuanyou/SAFECount] Query - How to deal with the originalimage size and examplar scales (Issue #19)

Thanks for your help. It makes sense now.

Following by that, have you considered using the original image to get features from resnet18 and rescale them afterwards? In other words, have you considered the difference between

resnet18(resize(image))

resize(resnet18(image))

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you modified the open/close state.Message ID: @.***>