bridgeqiqi / DIP2021-FinalPJbaseline

This repository is for DIP curriculum final project. The baseline model CSRNet is provided.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DIP2021-FinalPJbaseline

This repository is for DIP curriculum final project. The baseline model CSRNet is provided.

Environment & Folders

  • python 3.7.4
  • pytorch 1.4.0
  • torchvision 0.5.0
  • numpy 1.18.5
  • tensorboard 2.2.1

This pipeline is a simple framework for crowd counting task including four folders(datasets, losses, models, optimizers, Make_Datasets) and three files(main.py, test.py, train.sh).

  • main.py: The entrance of the main program.
  • test.py: Compute the MAE and RMSE metrics among testset images based on your checkpoints.
  • train.sh: You can run sh ./train.sh to launch training.
  • datasets: This folder contains dataloaders from different datasets.
  • losses: This folder contains different customized loss functions if needed.
  • models: This folder contains different models. CSRNet is provided here.
  • optimizers: This folder contains different optimzers.
  • Make_Datasets: This folder contains density map generation codes.

Datasets Preparation

The density map generation codes are in Make_Datasets folders.

After all density maps are generated, run ls -R /xx/xxx/xxx/*.jpg > train.txt, ls -R /xx/xxx/xxx/*.jpg > val.txt, ls -R /xx/xxx/xxx/*.jpg > test.txt to generate txt files for training, validating and testing.

Quick Start for Training and Testing

  • Training

run sh ./train.sh or run the following command.

python main.py --dataset shanghaitechpa \
--model CSRNet \
--train-files /home/jqgao/workspace/CrowdCounting/TrainingTestingFileLists/ShanghaiTechPartA_full_origin_train.txt \
--val-files /home/jqgao/workspace/CrowdCounting/TrainingTestingFileLists/ShanghaiTechPartA_full_origin_val.txt \
--gpu-devices 4 \
--lr 1e-5 \
--optim adam \
--loss mseloss \
--checkpoints ./checkpoints/demo \
--summary-writer ./runs/demo
  • Testing

run the following command.

python test.py --test-files /home/jqgao/workspace/CrowdCounting/TrainingTestingFileLists/ShanghaiTechPartA_full_origin_test.txt --best-model /home/jqgao/workspace/DIP2021/checkpoints/demo/bestvalmodel.pth

NWPU-Crowd Contest Platform

https://www.crowdbenchmark.com/nwpucrowd.html

Reference

About

This repository is for DIP curriculum final project. The baseline model CSRNet is provided.


Languages

Language:Python 99.1%Language:Shell 0.9%