Skip to content

This repository performs crowd counting inference using a pre-trained ONNX model. Input an image to estimate head localization in crowded scenes.

Notifications You must be signed in to change notification settings

links-ads/starlight-crowd-counting-inference

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crowd Counting Inference

Input and output example of crowded inference This repository contains code for performing crowd counting inference using a pre-trained model. The code allows you to input an image and obtain estimated head localization points in crowded scenes. The inference is based on a trained ONNX model that has been optimized for crowd counting tasks.

How to Run

  1. Clone the repository to your local machine:
git clone https://github.com/your-username/crowd-counting-inference.git
cd crowd-counting-inference
  1. Install the required dependencies. It's recommended to use a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
  1. Import the library and run the inference:
from crowd_counting_inference import CrowdCountingModel
# ... other imports

# Specify the path to your YAML file
CONFIG_FILE = "path/to/config"

if __name__ == "__main__":
    # Load config
    with open(CONFIG_FILE, "r") as yaml_file:
        config = yaml.safe_load(yaml_file)

    # Load the sample image
    img = ...

    # Create and run the model
    runtime = CrowdCountingModel(
        model_path=config["model_path"],
        providers=config["providers"],
        head_threshold=config["head_threshold"],
        patch_size=config["patch_size"],
        batch_size=config["batch_size"],
    )
    pred_points = runtime.inference(np.array(img))

Every ONNX file is associated to a model configuration (a .yaml file). Model weights have not been uploaded to the repository due to the large size, if you wish to run the code please reach to fabio.montello[at]linksfoundation.com.

About

This repository performs crowd counting inference using a pre-trained ONNX model. Input an image to estimate head localization in crowded scenes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages