Giter Site home page Giter Site logo

tugot17 / yolo-object-counting-api Goto Github PK

View Code? Open in Web Editor NEW
208.0 7.0 57.0 72.03 MB

The code of the Object Counting API, implemented with the YOLO algorithm and with the SORT algorithm

License: GNU General Public License v3.0

Python 100.00%
object-counting object-counting-api object-counter yolo yolov2 object-detection opencv computer-vision vehicle-tracking vehicle-detection

yolo-object-counting-api's Introduction

YOLO-Object-Counting-API

Real time Object Counting api. Implemented with the YOLO algorithm and with the SORT algorithm

The implementation is using model in same format as darkflow and darknet. Weight files, as well as cfg files can be found here. Darklow supports only YOLOv1 and YOLOv2. Support for YOLOv3 has not yet been implemented.

In order to achieve the best performance, you should have Cuda and tensorflow-gpu installed on Your device.

Demo

Count objects of a specified class crossing a virtual line

Counting pedestrains

Highway traffic counting

Count objects on a video

Count objects on a single frame

Set up

Dependencies

-tensorflow 1.0
-numpy
-opencv 3

Getting started

You can choose one of the following three ways to get started with darkflow.

  1. Just build the Cython extensions in place. NOTE: If installing this way you will have to use ./flow in the cloned darkflow directory instead of flow as darkflow is not installed globally.

    python3 setup.py build_ext --inplace
    
  2. Let pip install darkflow globally in dev mode (still globally accessible, but changes to the code immediately take effect)

    pip3 install -e .
    
  3. Install with pip globally

    pip3 install .
    

Required files

The YOLO algoritym impementation used in this project requires 3 files. Configuration of network (.cfg), trained weights (.weights) and labels.txt.

YOLO implementation used in this project enables usage of YOLOv1 and YOLOv2, and its tiny versions. Support for YOLOv3 has not yet been implemented.

.cfg files

Configuration file determines a network architecture. Configurations can be found here. In example scripts we assume that the configuration is placed in cfg/ folder. Location of used .cfg file is specyfied in the options object used in the code.

The .cfg file can be downloaded using the following command:

wget https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov2.cfg -O cfg/yolov2.cfg

.weights files

The .weights files contain trained parameters of a network. In example scripts we assume the weights are placed in bin/ folder. Location of used .weights file is specyfied in the options object used in the code.

The .weights file can be downloaded using the following command:

wget https://pjreddie.com/media/files/yolov2.weights -O bin/yolov2.weights

labels.txt files

This file is list of classes detected by a YOLO netowork. It shoud contain as many classes as it is specyfied in a .cfg file.

Run counting

Once You have all dependencies instaled and all required files You can start counting objects. Object counting is carried out by an ObjectCuntingAPI object.

Examples of counting below

Count cars on crosing a virtual line

python3 count_cars_crosing_virtual_line.py

Count objects on video from Video Camera

python3 count_objects_from_camera.py

Count people on image

python3 count_people_on_image.py

Credits

The following open source projects were used in the implementation

Darkflow

The YOLO algorithm impementation - Darkflow

Python Traffic Counter

Object counting with YOLO and SORT. Similar project, but instead of using the darklow YOLO implementation, it uses the opencv YOLO implementation, so there is no GPU acceleration.

Deep Sort

Object tracking and counting - SORT

Images and Videos sources

Highway surveillance video

Pedestrian surveillance video

Authors

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details

That's all.

yolo-object-counting-api's People

Contributors

abagshaw avatar alexfridman avatar allanzelener avatar arionik avatar azza-bazoo avatar bafu avatar borasy avatar dependabot[bot] avatar dhruv-mohan avatar dkermany avatar hajapy avatar holyguacamole avatar kevinkit avatar lilohuang avatar loretoparisi avatar lunardog avatar matteo-dunnhofer avatar offchan42 avatar oulutan avatar pjnr1 avatar prakash19921206 avatar ryanferg avatar ryansun1900 avatar silvergasp avatar thtrieu avatar tugot17 avatar tungalbert99 avatar zayfod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

yolo-object-counting-api's Issues

No module named 'darkflow.cython_utils.cy_yolo_findboxes

Hey guys,

let's start this issue from the beginning what I have done so far:

  1. Darkflow is already on virtual env.
  2. I created my own darkflow model from scratch - which is also working because he is detecting my objects properly on video and images
  3. Now I was trying to implement a counting algorithm, and came across this thread. Since this is exactly the way I want to do it, by letting objects pass a line and then count them I thought I'll give it a shot.
  4. I installed darkflow globally with pip install -e. . This should have worked, because if i pip show darkflow I get the following output:
    Name: darkflow Version: 1.0.0 Summary: Darkflow Home-page: https://github.com/thtrieu/darkflow Author: UNKNOWN Author-email: UNKNOWN License: GPLv3 Location: MyLocation Requires: Required-by:

Now to the Problem:
No module named 'darkflow.cython_utils.cy_yolo_findboxes

The Location MyLocation, however, is not the same as this repo. To fix this I treid following:

  1. Merge all the files together, so that the old darkflow repo and the new YOLO API from here would match, and all the new files are inserted.
  2. This led me to the next problem `No module named 'filterpy'

Would really appreciate some help. Like already said I have my, from scratch trained yolo model, with the 4 ckpt files (where I use XXX.meta file as weights file) and would love to count my objects if they pass a specific line in the video. I think the harder part is already done with the model creation, but I dont have the insights in the code to fully understand where I get all my coordinates for the bounding boxes to calculate centroids and furthermore assign IDs and count those.

BR

Error in some C files

Hi the count_cars_crosing_virtual_line.py began to run but I encountered this:

File "d:\custom code\YOLO-Object-Counting-API\darkflow\net\yolo\predict.py", line 8, in
from ...cython_utils.cy_yolo_findboxes import yolo_box_constructor
ModuleNotFoundError: No module named 'darkflow.cython_utils.cy_yolo_findboxes'

even though the C file is there

Import Error in running count_cars_crossing_virtual_line.py

So since last time I created a new environment "C:/Users/Owner/anaconda3/envs/newenvt/python.exe" installed cuda version: 10.0
and cudnn-10.0v7.6.4.38 then I installed tensorflow in the new environment without any errors then I tried to run the file in the title and then this error shows up:
Screenshot 2021-07-03 134017

I also modified object_counting_api.py since it had a syntax error at line 33 to "f{label}: {quantity}"
can you help me with this please ?

SyntaxError: invalid syntax

File "count_cars_crosing_virtual_line.py", line 2, in
from object_counting_api import ObjectCountingAPI
File "/home/nims/Downloads/YOLO-Object-Counting-API-master (2)/object_counting_api.py", line 33
f"{label}: {quantity}",
^
SyntaxError: invalid syntax

Please help me

Darkflow

Is there a need to follow any one of the three steps mentioned for darkflow if i have download this complete repository?

error in getting started

Hi I cloned another repo that uses tensor flow that has the same getting started section however I tried all 3 ways of and the last one did this:
124121820-a50c2f00-da75-11eb-8cd7-034ff6ba59da
124121806-a0e01180-da75-11eb-9bbf-efea0f3abe12
124121809-a2a9d500-da75-11eb-88d9-bc744ecdfc51
124121813-a3426b80-da75-11eb-9af4-a2ff33f84945

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.