Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crowd Risk Score (CRS)

overview

Clone Repository

git clone git@github.com:haruto2002/Crowd-Risk-Score.git
cd Crowd_Risk_Score

Virtual Environment Setup

curl -LsSf https://astral.sh/uv/install.sh | sh

uv venv --python 3.12

source .venv/bin/activate

Usage

Data Preparation

Trajectory Data

You can download the trajectory data from Google Drive: Trajectory Data

The following directory structure is required:

trajectory_data/
└── WP_0001/
    ├── track_frame_data/
    │   ├── 0001.txt
    │   ├── 0002.txt
    │   └── ...
    ├── homography_matrix.txt
    └── map_size.txt

Evaluation Dataset

You can download the datasets from Google Drive: Dataset

The following directory structure is required:

dataset/
└── WP_0001/
    ├── classification/
    │   ├── 0001.json
    │   ├── 0002.json
    │   └── ...
    └── pairwise_comparison/
        ├── 0001.json
        ├── 0002.json
        └── ...
Classification Dataset
  "frame_range": Target frame range in trajectory_data >> [start_frame, end_frame]
  "crop_points": Target area in trajectory_data >> [top_left_x, top_left_y, bottom_right_x, bottom_right_y]
  "GT_A": Annotator A's classification judgment >> 0(Safe) or 1(Danger)
  "GT_B": Annotator B's classification judgment >> 0(Safe) or 1(Danger)
  "GT_same": Agreement/disagreement between two annotators >> True or False
Pairwise Comparison Dataset
  "1", "2": Information for two scenes to be compared, each containing:
  - "frame_range": Target frame range in trajectory_data >> [start_frame, end_frame]  
  - "crop_points": Target area in trajectory_data >> [top_left_x, top_left_y, bottom_right_x, bottom_right_y]  

  "Judgement":  
  - "GT_A": Annotator A's comparison judgment >> 1("1" is higher risk) or 2("2" is higher risk)  
  - "GT_B": Annotator B's comparison judgment >> 1("1" is higher risk) or 2("2" is higher risk)   
  - "GT_same": Agreement/disagreement between two annotators >> True or False

Program Execution

Calculating Crowd Risk Score for Trajectory Data

Specifying variables via command line
uv run python src/main.py \
    --results_base_dir_name results \
    --dir_name demo \
    --trajectory_dir trajectory_data/WP_0001 \
    --grid_size 5 \
    --vec_span 10 \
    --freq 10 \
    --R 13.5 \
    --frame_start 1 \
    --frame_end 8990
Using YAML configuration file

Edit the src/config/config.yaml file to set the required parameters:

results_base_dir_name: results
dir_name: demo
trajectory_dir: trajectory_data/WP_0001
crop_area: null
frame_range:
- 1
- 8990
freq: 10
R: 13.5
grid_size: 5
vec_span: 10
uv run python src/main.py --use_yaml --yaml_path src/config/config.yaml
Parameter Description
  • results_base_dir_name: Base directory name for saving results
  • dir_name: Output directory name
  • trajectory_dir: Directory path for trajectory data
  • crop_area: Crop area (null for entire area)
  • frame_range: Frame range to process [start, end]
  • freq: Frame interval for risk calculation
  • R: Radius parameter for Gaussian kernel
  • grid_size: Grid size
  • vec_span: Vector calculation span

Calculating scores corresponding to the dataset

# Pairwise comparison dataset
uv run python metric/set_prediction.py --path2dataset dataset/WP_0001/pairwise_comparison --dataset_type pairwise_comparison --pred_dir results/demo

# Classification dataset
uv run python metric/set_prediction.py --path2dataset dataset/WP_0001/classification --dataset_type classification --pred_dir results/demo

Calculating evaluation metrics

# Pairwise comparison dataset
uv run python metric/calc_metric.py --path2dataset dataset/WP_0001/pairwise_comparison --dataset_type pairwise_comparison --pred_dir results/demo --eval_column crs

# Classification dataset
uv run python metric/calc_metric.py --path2dataset dataset/WP_0001/classification --dataset_type classification --pred_dir results/demo --eval_column crs

Output

After execution, the following directory will be created:

results/demo/
├── each_result/
│   ├── crs_map/
│   │   ├── 0001_0011.txt
│   │   ├── 0011_0021.txt
│   │   └── ...
│   ├── vec_data/
│   │   ├── 0001_0011.txt
│   │   ├── 0011_0021.txt
│   │   └── ...
│   └── config.yaml
├── pred_data/
└── metric_results/

Project Structure

Crowd_Risk_Score/
├── src/
│   ├── main.py              # Main execution file
│   ├── config/
│   │   └── config.yaml      # Configuration file
│   └── utils/
│       ├── clac_crowd_risk_score.py  # CRS calculation
│       └── get_track_data.py         # Trajectory data processing
├── dataset/
│   └──WP_0001/
│       ├── classification/
│       └── pairwise_comparison/
├── metric/                   # Evaluation metric calculation
│   ├── calc_classification_scores.py  # Classification score calculation
│   ├── calc_metric.py                 # Metric calculation
│   ├── set_classification_pred.py     # Classification prediction setup
│   ├── set_prediction.py             # Prediction setup
│   ├── set_pairwise_pred.py          # Pairwise prediction setup
│   ├── calc_precision.py             # Precision calculation
│   └── utils.py                      # Utility functions
├── results/                 # Result output
├── trajectory_data/         # Trajectory data
└── README.md

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages