Skip to content

simurgh7/CrowdGen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CrowdGen

Official Implementation of "Generative Adversarial Perturbations with Cross-paradigm Transferability on Localized Crowd Counting"

Venue: CVPR 2026 Main Conference

This repository implements generative adversarial perturbations for crowd counting networks. Representative methods for both density map (SASNet) and point regression (P2PNet) paradigms are provided.

📁 General Project Structure

├── Crowd Model/                     # Density Map or Point Regression approach
│   ├── datasets/
│   │   ├── dataset.py               # Dataloader
│   │   └── make_npydata.py          # Data Organizer
│   ├── models/
│   │   ├── model.py                 # One or more files for Crowd Localized Counting Model
│   │   └── unet.py                  # Perturbation Generator Network
│   ├── util/                        # Optional for specific methods
│   ├── attack_unet.py               # Train perturbation generator
│   ├── camgen.py                    # GradCAM extraction process for backbone
│   ├── config.py                    # Configuration with flag support
│   ├── engine.py                    # Evaluation functions
│   ├── explain.py                   # CAM explanations
│   └── inference.py                 # Side-by-side comparison (clean vs. adversarial)
└── data/                            # Data directory (create this for SHHA, UCF, JHU, NWPU)
    ├── image_data/                  # Images (e.g., 1.jpg)
    └── gt_data/                     # Ground truth (e.g., 1.h5)

🚀 Quick Start

Data Preparation

Place images and ground truth in data/image_data/ and data/gt_data/ with matching names (e.g., 1.jpg and 1.h5). Run datasets/make_npydata.py to generate file lists that can be placed in datasets/npydata/ folder. Run the same after adversarial image generation, gt is not needed this time, the list of images should be enough.

Training Perturbation Generator

config.py contains all configurable parameters. Override any attribute using command-line flags

Density Map approach

cd 2021_AAAI_SASNet_DM
python attack_unet.py --epochs 50 --batch_size 8

Point Regression approach

cd 2021_ICCV_P2PNet_PR
python attack_unet.py  --epochs 50 --batch_size 8

Evaluation Side by Side

python <Crowd Model>/inference.py --model_path ./weights/model.pth --adv_npy_path ./datasets/npydata/shha_adv.npy --clean_npy_path ./datasets/npydata/shha_clean.npy

About

This is the official implementation of the paper " Generative Adversarial Perturbations with Cross-paradigm Transferability on Localized Crowd Counting" that was accepted in CVPR 2026.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages