项目作者: TannerGilbert

项目描述 :
Cumulative object counting with Tensorflow 2
高级语言: Python
项目地址: git://github.com/TannerGilbert/Tensorflow-2-Object-Counting.git
创建时间: 2020-12-30T10:58:00Z
项目社区:https://github.com/TannerGilbert/Tensorflow-2-Object-Counting

开源协议:MIT License

下载


Tensorflow 2 Object Counting

Cummulative object counting with Tensorflow 2 and Tensorflow Lite.

Cumulative counting example

Installation

  1. Clone the repository
    git clone https://github.com/TannerGilbert/Tensorflow-2-Object-Counting

  2. Install the Tensorflow Object Detection API

  3. Install dependencies

    1. cd Tensorflow-2-Object-Counting
    2. pip3 install -r requirements.txt

Cumulative counting with Tensorflow

To run cumulative counting with a Tensorflow object detection model use the tensorflow_cumulative_object_counting.py script.

  1. usage: tensorflow_cumulative_object_counting.py [-h] -m MODEL -l LABELMAP [-v VIDEO_PATH] [-t THRESHOLD] [-roi ROI_POSITION] [-la LABELS [LABELS ...]] [-a] [-s SKIP_FRAMES] [-sh] [-sp SAVE_PATH]
  2. Detect objects inside webcam videostream
  3. optional arguments:
  4. -h, --help show this help message and exit
  5. -m MODEL, --model MODEL
  6. Model Path
  7. -l LABELMAP, --labelmap LABELMAP
  8. Path to Labelmap
  9. -v VIDEO_PATH, --video_path VIDEO_PATH
  10. Path to video. If None camera will be used
  11. -t THRESHOLD, --threshold THRESHOLD
  12. Detection threshold
  13. -roi ROI_POSITION, --roi_position ROI_POSITION
  14. ROI Position (0-1)
  15. -la LABELS [LABELS ...], --labels LABELS [LABELS ...]
  16. Label names to detect (default="all-labels")
  17. -a, --axis Axis for cumulative counting (default=x axis)
  18. -s SKIP_FRAMES, --skip_frames SKIP_FRAMES
  19. Number of frames to skip between using object detection model
  20. -sh, --show Show output
  21. -sp SAVE_PATH, --save_path SAVE_PATH
  22. Path to save the output. If None output won't be saved

Example:
python tensorflow_cumulative_object_counting.py -m model_path/saved_model -l labelmap.pbtxt -v video.mp4 -a

Tensorflow cumulative object counting example

Cumulative counting with Tensorflow Lite

To run cumulative counting with a Tensorflow Lite model use the tflite_cumulative_object_counting.py script.

  1. usage: tflite_cumulative_object_counting.py [-h] -m MODEL -l LABELMAP [-v VIDEO_PATH] [-t THRESHOLD] [-roi ROI_POSITION] [-la LABELS [LABELS ...]] [-a] [-e] [-s SKIP_FRAMES] [-sh] [-sp SAVE_PATH] [--type {tensorflow,yolo,yolov3-tiny}]
  2. optional arguments:
  3. -h, --help show this help message and exit
  4. -m MODEL, --model MODEL
  5. File path of .tflite file. (default: None)
  6. -l LABELMAP, --labelmap LABELMAP
  7. File path of labels file. (default: None)
  8. -v VIDEO_PATH, --video_path VIDEO_PATH
  9. Path to video. If None camera will be used (default: )
  10. -t THRESHOLD, --threshold THRESHOLD
  11. Detection threshold (default: 0.5)
  12. -roi ROI_POSITION, --roi_position ROI_POSITION
  13. ROI Position (0-1) (default: 0.6)
  14. -la LABELS [LABELS ...], --labels LABELS [LABELS ...]
  15. Label names to detect (default="all-labels") (default: None)
  16. -a, --axis Axis for cumulative counting (default=x axis) (default: True)
  17. -e, --use_edgetpu Use EdgeTPU (default: False)
  18. -s SKIP_FRAMES, --skip_frames SKIP_FRAMES
  19. Number of frames to skip between using object detection model (default: 20)
  20. -sh, --show Show output (default: True)
  21. -sp SAVE_PATH, --save_path SAVE_PATH
  22. Path to save the output. If None output won't be saved (default: )
  23. --type {tensorflow,yolo,yolov3-tiny}
  24. Whether the original model was a Tensorflow or YOLO model (default: tensorflow)

Example:
python tflite_cumulative_object_counting.py -m model.tflite -l labelmap.txt -v video.mp4 -a

TFLITE cumulative object counting example

Inspired by / Based on

This project was inspired by OpenCV People Counter and the tensorflow_object_counting_api.