Skip to content

Implement SANet for crowd counting in Keras.

License

Notifications You must be signed in to change notification settings

zhangsong1213/SANet-Keras

 
 

Repository files navigation

SANet-Keras

An unofficial implementation of SANet for crowd counting in Keras-TF.


Paper:

Results now:

On dataset ShanghaiTech B

Still far from the performance in the original paper(MAE 8.4)

MAE MSE MAPE Mean DM Distance
13.727 22.726 11.9 27.065

Dataset:

Training Parameters:

  1. Loss = ssim_loss + L2

  2. Optimizer = Adam(lr=1e-4)

  3. Data augmentation: Flip horizontally.

  4. Patch: No patch, input the whole image, output the same shape DM.

  5. Instance normalization: No IN layers at present, since network with IN layers is very hard to train and IN layers didn't show improvement to the network in my experiments.

  6. Output Zeros: The density map output may fade to zeros in 95%+ random initialization, I tried the initialization method in the original paper while it didn't work. In the past, when this happens, I just restarted the kernel and re-run. But now, I tried to train different modules(1-5) separately in the first several epochs to get relatively reasonable weights:

    structure_lite, and it worked out to greatly decrease the probability of the zero-output-phenomena. Any other question, welcome to contact me.

  7. Weights: Got best weights in 251-th epoch(300 epochs in total), and here is the loss records:

    Loss_records

  8. Prediction example:

    example

Run:

  1. Download dataset;
  2. Data generation: run thegenerate_datasets.ipynb .
  3. Run the main.ipynb to train the model and do the test.

Abstraction:

  1. Network = encoder + decoder, model plot is here:

    Network encoder decoder
    Composition scale aggregation module conv2dTranspose
    Usage extract multi-scale features generate high resolution density map
  2. Loss:

    Loss = loss_formular

  3. Normalization layer:

    • Ease the training process;
    • Reduce 'statistic shift problem'.

About

Implement SANet for crowd counting in Keras.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 96.2%
  • Python 3.8%