GithubHelp home page GithubHelp logo

ahmetozlu / tensorflow_object_counting_api Goto Github PK

View Code? Open in Web Editor NEW
1.3K 58.0 544.0 333.89 MB

🚀 The TensorFlow Object Counting API is an open source framework built on top of TensorFlow and Keras that makes it easy to develop object counting systems!

Home Page: https://www.youtube.com/watch?v=yT_1eKJTdfk

License: MIT License

Python 100.00%
object-detection object-counting object-counting-api object-detection-api tensorflow tensorflow-api object-detection-label object-detection-pipelines opencv computer-vision

tensorflow_object_counting_api's Introduction

TensorFlow Object Counting API

The TensorFlow Object Counting API is an open source framework built on top of TensorFlow and Keras that makes it easy to develop object counting systems. Please contact if you need professional object detection & tracking & counting project with the super high accuracy and reliability!

QUICK DEMO


Cumulative Counting Mode (TensorFlow implementation):


Real-Time Counting Mode (TensorFlow implementation):



Object Tracking Mode (TensorFlow implementation):


Object Counting On Single Image (TensorFlow implementation):


Object Counting based R-CNN (Keras and TensorFlow implementation):

Object Segmentation & Counting based Mask R-CNN (Keras and TensorFlow implementation):


BONUS: Custom Object Counting Mode (TensorFlow implementation):

You can train TensorFlow models with your own training data to built your own custom object counter system! If you want to learn how to do it, please check one of the sample projects, which cover some of the theory of transfer learning and show how to apply it in useful projects, are given at below.

Sample Project#1: Smurf Counting

More info can be found in here!

Sample Project#2: Barilla-Spaghetti Counting

More info can be found in here!


The development is on progress! The API will be updated soon, the more talented and light-weight API will be available in this repo!

  • Detailed API documentation and sample jupyter notebooks that explain basic usages of API will be added!

You can find a sample project - case study that uses TensorFlow Object Counting API in this repo.


USAGE

1.) Usage of "Cumulative Counting Mode"

1.1) For detecting, tracking and counting the pedestrians with disabled color prediction

Usage of "Cumulative Counting Mode" for the "pedestrian counting" case:

is_color_recognition_enabled = False # set it to true for enabling the color prediction for the detected objects
roi = 385 # roi line position
deviation = 1 # the constant that represents the object counting area

object_counting_api.cumulative_object_counting_x_axis(input_video, detection_graph, category_index, is_color_recognition_enabled, roi, deviation) # counting all the objects

Result of the "pedestrian counting" case:


Source code of "pedestrian counting case-study": pedestrian_counting.py


1.2) For detecting, tracking and counting the vehicles with enabled color prediction

Usage of "Cumulative Counting Mode" for the "vehicle counting" case:

is_color_recognition_enabled = True # set it to true for enabling the color prediction for the detected objects
roi = 200 # roi line position
deviation = 3 # the constant that represents the object counting area

object_counting_api.cumulative_object_counting_y_axis(input_video, detection_graph, category_index, is_color_recognition_enabled, roi, deviation) # counting all the objects

Result of the "vehicle counting" case:


Source code of "vehicle counting case-study": vehicle_counting.py


2.) Usage of "Real-Time Counting Mode"

2.1) For detecting, tracking and counting the targeted object/s with disabled color prediction

Usage of "the targeted object is bicycle":

is_color_recognition_enabled = False # set it to true for enabling the color prediction for the detected objects
targeted_objects = "bicycle" 

object_counting_api.targeted_object_counting(input_video, detection_graph, category_index, is_color_recognition_enabled, targeted_objects) # targeted objects counting

Result of "the targeted object is bicycle":

Usage of "the targeted object is person":

is_color_recognition_enabled = False # set it to true for enabling the color prediction for the detected objects
targeted_objects = "person"

object_counting_api.targeted_object_counting(input_video, detection_graph, category_index, is_color_recognition_enabled, targeted_objects) # targeted objects counting

Result of "the targeted object is person":

Usage of "detecting, counting and tracking all the objects":

is_color_recognition_enabled = False # set it to true for enabling the color prediction for the detected objects

object_counting_api.object_counting(input_video, detection_graph, category_index, is_color_recognition_enabled) # counting all the objects

Result of "detecting, counting and tracking all the objects":


Usage of "detecting, counting and tracking the multiple targeted objects":

targeted_objects = "person, bicycle" # (for counting targeted objects) change it with your targeted objects
is_color_recognition_enabled = False # set it to true for enabling the color prediction for the detected objects

object_counting_api.targeted_object_counting(input_video, detection_graph, category_index, is_color_recognition_enabled, targeted_objects) # targeted objects counting

2.2) For detecting, tracking and counting "all the objects with disabled color prediction"

Usage of detecting, counting and tracking "all the objects with disabled color prediction":

is_color_recognition_enabled = False # set it to true for enabling the color prediction for the detected objects

object_counting_api.object_counting(input_video, detection_graph, category_index, is_color_recognition_enabled) # counting all the objects

Result of detecting, counting and tracking "all the objects with disabled color prediction":

Usage of detecting, counting and tracking "all the objects with enabled color prediction":

is_color_recognition_enabled = True # set it to true for enabling the color prediction for the detected objects

object_counting_api.object_counting(input_video, detection_graph, category_index, is_color_recognition_enabled) # counting all the objects

Result of detecting, counting and tracking "all the objects with enabled color prediction":

3.) Usage of "Object Tracking Mode"

Just run object_tracking.py


For sample usages of "Real-Time Counting Mode": real_time_counting.py


The minimum object detection threshold can be set in this line in terms of percentage. The default minimum object detecion threshold is 0.5!

General Capabilities of The TensorFlow Object Counting API

Here are some cool capabilities of TensorFlow Object Counting API:

  • Detect just the targeted objects
  • Detect all the objects
  • Count just the targeted objects
  • Count all the objects
  • Predict color of the targeted objects
  • Predict color of all the objects
  • Predict speed of the targeted objects
  • Predict speed of all the objects
  • Print out the detection-counting result in a .csv file as an analysis report
  • Save and store detected objects as new images under detected_object folder
  • Select, download and use state of the art models that are trained by Google Brain Team
  • Use your own trained models or a fine-tuned model to detect spesific object/s
  • Save detection and counting results as a new video or show detection and counting results in real time
  • Process images or videos depending on your requirements

Here are some cool architectural design features of TensorFlow Object Counting API:

  • Lightweigth, runs in real-time
  • Scalable and well-designed framework, easy usage
  • Gets "Pythonic Approach" advantages
  • It supports REST Architecture and RESTful Web Services

TODOs:

  • TensorFlox2.x support will be provided.
  • Autonomus Training Image Annotation Tool will be developed.
  • GUI will be developed.

Theory

System Architecture

  • Object detection and classification have been developed on top of TensorFlow Object Detection API, see for more info.

  • Object color prediction has been developed using OpenCV via K-Nearest Neighbors Machine Learning Classification Algorithm is Trained Color Histogram Features, see for more info.

TensorFlow™ is an open source software library for numerical computation using data flow graphs. Nodes in the graph represent mathematical operations, while the graph edges represent the multidimensional data arrays (tensors) communicated between them.

OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products.

Tracker

Source video is read frame by frame with OpenCV. Each frames is processed by "SSD with Mobilenet" model is developed on TensorFlow. This is a loop that continue working till reaching end of the video. The main pipeline of the tracker is given at the above Figure.

Models

By default I use an "SSD with Mobilenet" model in this project. You can find more information about SSD in here.

Please, See the detection model zoo for a list of other models that can be run out-of-the-box with varying speeds and accuracies. You can easily select, download and use state-of-the-art models that are suitable for your requeirements using TensorFlow Object Detection API.

You can perform transfer learning on trained TensorFlow models to build your custom object counting systems!

Project Demo

Demo video of the project is available on My YouTube Channel.

Installation

Dependencies

Tensorflow Object Counting API depends on the following libraries (see requirements.txt):

  • TensorFlow Object Detection API
  • tensorflow==1.5.0
  • keras==2.0.8
  • opencv-python==4.4.0.42
  • Protobuf 3.0.0
  • Python-tk
  • Pillow 1.0
  • lxml
  • tf Slim (which is included in the "tensorflow/models/research/" checkout)
  • Jupyter notebook
  • Matplotlib
  • Cython
  • contextlib2
  • cocoapi

For detailed steps to install Tensorflow, follow the Tensorflow installation instructions.

TensorFlow Object Detection API have to be installed to run TensorFlow Object Counting API, for more information, please see this.

Important: Compatibility problems caused by TensorFlow2 version.

This project developed with TensorFlow 1.5.0 version. If you need to run this project with TensorFlow 2.x version, just replace tensorflow imports with tensorflow.compat.v1, and add tf.disable_v2_behavior that's all.

Instead of this import statement:

import tensorflow

use this:

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

Citation

If you use this code for your publications, please cite it as:

@ONLINE{
    author = "Ahmet Özlü",
    title  = "TensorFlow Object Counting API",
    year   = "2018",
    url    = "https://github.com/ahmetozlu/tensorflow_object_counting_api"
}

Author

Ahmet Özlü

License

This system is available under the MIT license. See the LICENSE file for more info.

tensorflow_object_counting_api's People

Contributors

ahmetozlu avatar cclauss 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  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

tensorflow_object_counting_api's Issues

Question about cumulative_object_counting_x_axis

Hello, having a bit of problem with pedestrian detection. tried the pedestrian detection demo with my video ( a narrow hallway ). Modified the ROI line also but i can't get it to pick up the person. Tried different model frozen .pb also without success.
The cumulative_object_counting_y_axis seems to work a little bit better for my case but I would like to put the ROI line on vertical or at least slanted at an angle to detect people passing through a doorway into and out of the hallway.

Here's an example . How would I go about moving the ROI on the door to the right ?
image

NameError: name 'urllib' is not defined

Hi, i'm getting this error
I hope you could help me, thanks in advance

~\AppData\Local\Continuum\anaconda3\lib\site-packages\utils\backbone.py in set_model(model_name)
25 # Download Model if it has not been downloaded yet
26 if (model_found == 0):
---> 27 opener = urllib.request.URLopener()
28 opener.retrieve(download_base + model_file, model_file)
29 tar_file = tarfile.open(model_file)

NameError: name 'urllib' is not defined

What if the data is image?

How would I apply it to my code??

import os
import cv2
import numpy as np
import tensorflow as tf
import sys

sys.path.append("..")

from utils import label_map_util
from utils import visualization_utils as vis_util
from api import object_counting_api

MODEL_NAME = 'inference_graph'
IMAGE_NAME = 'tree.jpg'

CWD_PATH = os.getcwd()

PATH_TO_CKPT = os.path.join(CWD_PATH,MODEL_NAME,'frozen_inference_graph.pb')

PATH_TO_LABELS = os.path.join(CWD_PATH,'training','labelmap.pbtxt')

PATH_TO_IMAGE = os.path.join(CWD_PATH,IMAGE_NAME)

NUM_CLASSES = 2

label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
categories = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES, use_display_name=True)
category_index = label_map_util.create_category_index(categories)

detection_graph = tf.Graph()
with detection_graph.as_default():
od_graph_def = tf.GraphDef()
with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='')

sess = tf.Session(graph=detection_graph)

image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')

detection_boxes = detection_graph.get_tensor_by_name('detection_boxes:0')

detection_scores = detection_graph.get_tensor_by_name('detection_scores:0')
detection_classes = detection_graph.get_tensor_by_name('detection_classes:0')

num_detections = detection_graph.get_tensor_by_name('num_detections:0')

image = cv2.imread(PATH_TO_IMAGE)
image_expanded = np.expand_dims(image, axis=0)

(boxes, scores, classes, num) = sess.run(
[detection_boxes, detection_scores, detection_classes, num_detections],
feed_dict={image_tensor: image_expanded})

vis_util.visualize_boxes_and_labels_on_image_array(
image,
np.squeeze(boxes),
np.squeeze(classes).astype(np.int32),
np.squeeze(scores),
category_index,
use_normalized_coordinates=True,
line_thickness=1,
min_score_thresh=0.80)

cv2.imshow('Object detector', image)

cv2.waitKey(0)

cv2.destroyAllWindows()

Producing CSV file after counting

Hi Ahmet,

What is the process of creating a .csv file after the counting is complete?

I would like to see the output of the number and classes that the classifier picked up.

Thanks,

Custom Model Training

Hi @ahmetozlu I am enthusiastic about developing this API further and adding the custom model/data capabilities to it.
I believe the first step for me would be to do a thorough reading of the API code and get to know the bits.
I'll get back to you with my ideas when I have gone through the code and have a roadmap.

Regards.

Pedestrian counting

Hi,
I'm a somewhat newbie to deep-learning and therefore I would be pleased if you have time to answer my questions.

Situation
Now I'm doing research on how the pedestrian traffic influences the traffic of bank's offices located nearby. So my goal at this stage is to count correctly the number of people passing by the office. I was intended to use DVR(or another camera) located near the window inside the bank office. Consequently, the camera will be located on the side.

So, my questions:

  1. Are there any ready-to-go packages on python which would help to count pedestrians accurately (in my situation described above)? Is it possible?
  2. If it's possible, can you recommend some python solution (besides yours) for my purposes? As I already mentioned, I'm respectively new in this area and your solution is the best one I've googled.
  3. I used your code (https://github.com/ahmetozlu/tensorflow_object_counting_api/blob/master/pedestrian_counting.py) for your sample video, and didn't count pedestrians right. Specifically, I obtained the figure of 6 people passed through the line (while the real amount is 13). Are your results the same? Or maybe I'm doing something wrong?

I would be very grateful if you have time to answer.

Code-question: Comparison of the detected objects from different fames

Hello Ahmet,

I'm currently working on a student project with Tensorflow. I think I understood the important things of your implementation. But I have one problem. When you detect the object and you want to identify the moving direction of the object with the frame-pixels of the frame before, how do you know that the object of the new frame is the same object like the object of frame before?

Thank you

Error while run single_image_object_counting.py

When I run single_image_object_counting.py there is an error like this:

$ python single_image_object_counting.py
Traceback (most recent call last):
File "single_image_object_counting.py", line 28, in <module>
result = object_counting_api.single_image_object_counting(input_video, detection_graph, category_index, is_color_recognition_enabled, fps, width, height) # targeted objects counting
File "/root/tensorflow_object_counting_api/api/object_counting_api.py", line 469, in single_image_object_counting
feed_dict={image_tensor: image_np_expanded})
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 900, in run run_metadata_ptr)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1058, in _run
raise RuntimeError('Attempted to use a closed Session.')
RuntimeError: Attempted to use a closed Session.

How to solve this?

Problems in counting

If we are counting some object and when object passes through a line which counts passing of any object. But when any object stays on line, so it's keep on counting that object again and again. Please suggest a change to fix that

counting error

hi, thanks for your great job! I successfully ran the script 'vehicle_counting.py', but when I check the result 'output.avi', it seems some errors happened:

  1. vehicle counting: in the resulting video, the value of vehicle through the roi_position cannot match with vehicle counting that presents in the video.
  2. error bbox: in the resulting video, there are some blue bounding box labelled 'smurf', which makes me so confused that what is the problems?

Can you help me fix this problems? Thanks a lot!

Threshold and false positives

Hello, how can I adjust a threshold ? I remember before was playing with other examples and they used something like classes[i] == 1 -> this is person
and scores[i] > my threshold but can't find anything like this in this code.
This were obtained from (boxes, scores, classes, num) = self.sess.run(some stuff)

AttributeError: module 'tensorflow' has no attribute 'GraphDef'

hello
I am getting this error saying module tensor flow has no attribute 'GraphDef '
but i installed latest version of tensor flow in my machine and i am getting this error at all files like vehicle-counting, real_time_counting_targeted_object etc .
can somebody help me because i am new to this deep learning ..

this is what it shows .

PS C:\Users\DELL\desktop\tensor\tflw> python vehicle_counting.py
Traceback (most recent call last):
File "vehicle_counting.py", line 17, in
detection_graph, category_index = backbone.set_model('ssd_mobilenet_v1_coco_2018_01_28')
File "C:\Users\DELL\desktop\tensor\tflw\utils\backbone.py", line 38, in set_model
od_graph_def = tf.GraphDef()
AttributeError: module 'tensorflow' has no attribute 'GraphDef'

thanks.

Error while running single image object counting . py

I am working on a project called " product recognition in Super Market Shelves ". I have images of shelves with products like Maggi and Dark Fantacy and I am able to detect these products with TF object detection API. Now I want to count how many number of maggi and how many number of dark fantacy is there in given image. So I thought , I can achieve this by using your TF object Counting API and I executed Single Image Object Counting .py program. When I am executing I got error as below.
screenshot from 2018-09-24 10-42-24

Using own trained model

Hello, i try to substitute the model with my own model (mobilenet ssd v2 model trained with own dataset). But, could not make it work. Anyone has any idea how to make it work? The following is the error that occured

`File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/importer.py", line 418, in import_graph_def
graph._c_graph, serialized, options) # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: NodeDef mentions attr 'T' not in Op<name=NonMaxSuppressionV3; signature=boxes:float, scores:float, max_output_size:int32, iou_threshold:float, score_threshold:float -> selected_indices:int32>; NodeDef: {{node Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/non_max_suppression/NonMaxSuppressionV3}} = NonMaxSuppressionV3[T=DT_FLOAT](Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/unstack, Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/Reshape, Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/Minimum, Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/non_max_suppression/iou_threshold, Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/non_max_suppression/score_threshold). (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "pedestrian_counting.py", line 21, in
detection_graph, category_index = backbone.set_model('ssd_mobilenet_v2')
File "/notebooks/tensorflow_object_counting_api/utils/backbone.py", line 44, in set_model
tf.import_graph_def(od_graph_def, name='')
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
return func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/importer.py", line 422, in import_graph_def
raise ValueError(str(e))
ValueError: NodeDef mentions attr 'T' not in Op<name=NonMaxSuppressionV3; signature=boxes:float, scores:float, max_output_size:int32, iou_threshold:float, score_threshold:float -> selected_indices:int32>; NodeDef: {{node Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/non_max_suppression/NonMaxSuppressionV3}} = NonMaxSuppressionV3[T=DT_FLOAT](Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/unstack, Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/Reshape, Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/Minimum, Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/non_max_suppression/iou_threshold, Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/non_max_suppression/score_threshold). (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).`

Thank You.

Comment tensorflow checking line

Hi, I think you have to comment the line checking the tensorflow version.
But the rest of the code works perfectly.
Thanks a lot.

Car Counting detect nothing

Hi,
I run your Vehicle Counting script, but it can't detect any vehicle. it's 0
The script run successfully but the result video can't detect any vehicle.
Anything advice?

Thanks;

Code Implementation

I am getting the error-
Traceback (most recent call last): File "carxcount.py", line 22, in <module> detection_graph, category_index = backbone.set_model('ssd_mobilenet_v1_coco_2017_11_17') NameError: name 'backbone' is not defined

Vehicle Counting

Hi, can we add targeted_objects = "car, bus, truck" in vehicle_counting.py file i want to count upon these target objects.
how to update this code to specifically detect upon these targeted_objects = "car, bus, truck"??

need help

run with webcam live

Hello,

Please how can i test it with my live webcam ?
I have tested on input videos as in showed in the tuto but i want to do live detection using my ubuntu webcam. IS there any option to do this please ?

Thank you in advance

How to access to video duration?

Hi, Iam Running real_time_counting.py script it works great.Thanks for sharing!

I need to access to the video duration,
I mean I need output in which second of video which objects are detected..
( example: 00:01 second : 1 truck,2 persons... , 00:02 second : 3 persons,1 car are detected ... etc.)

How it is possible? Or it will be upgradet on this project?

Config file used for training

I am interested in training an SSD model myself and I was wondering if you could provide the config file you used to train your model.
Your model seem to work quite well for detecting objects.

I have downloaded the samples from model in tensorflow object detection but somehow I feel I am missing something.

DRY Priniciples for the Main API File

It looks like the main API file could be cleaned up a bit, as a lot of code is repeated.

Let me know if you're OK with me doing this, and I'll submit a PR in the next two weeks.

Error while running single_image_object_counting.py

Hi. I am trying to run the single_image_object_counting.py file but i keep running into Runtimeerror: Attempted to use a closed session.

I saw the other threads and tried changing the object detection api file but it didnt work as well. I am trying to count the number of dogs and cats using my own test data.

Traceback (most recent call last):
File "C:\tensorflow1\model\research\object_detection\single_image_object_counting.py", line 26, in
result = object_counting_api.single_image_object_counting(input_video, detection_graph, category_index, is_color_recognition_enabled, fps, width, height) # targeted objects counting
File "C:\tensorflow1\model\research\object_detection\api\object_counting_api.py", line 475, in single_image_object_counting
counter, csv_line, counting_mode = vis_util.visualize_boxes_and_labels_on_single_image_array(1,input_frame,
AttributeError: module 'utils.visualization_utils' has no attribute 'visualize_boxes_and_labels_on_single_image_array'

Can you help me please

Multiple target objects

Hi,

How can we count multiple target objects at a give time, for example in place of placing target objects as person or car at an instant, how can we pass both of them to the counting at the same moment ?

Inaccurate count

When I run vehicle_counting. py,so I would like to ask where in the code the range of counts changes and I found that the pedestrian count was accurate and the car count was not.
In addition, I would like to ask what is the benchmark for counting cars through the line, and how can I achieve count=1? I feel that there is something wrong with the benchmark of this range

Separate Util Modifications

I understand that some of Tensorflow's util files had to be modified for this to work; however, I believe this API could be made more elegant if there were a separation between the default utils and edited utils.

I'll implement a PR for this sometime in the next two weeks.

How to count the number of any class which is not present in COCO dataset?

I have been building a toy(which is not present in COCO) detection dataset based in tensorflow object detection API. I have followed this github repository for my project model,Github.

But now I also want to count the number of toys present and saw your repository.
Can you please tell what should I change in this Github repository and the information which I can use from my previous work.

How to count people with a live video feed

Hi ahmetozlu, i want to use your api for counting the amount of people within a camera feed and then saving the number to a text file. How do i go about implementing your code into my code to do that, I have attached my code.

Please feel free to message me or alter my code in any way to get a better result. Thank you :)
people detection

Stereopi and Google Coral USB Accelerator

Ahmet bey,

First of all, thank you very much for this wonderful project. We are looking into integrating this project to do human counting for our open-source project SandStar automation system. We are looking into integrating it with stereopi and Google coral usb accelerator.

my question is:

  • Is coral module fast enough to handle calculations with TensorFlow lite?

We will be open-sourcing the whole implementation of it.

unable to open file: name = 'mask_rcnn_barilla-spaghetti_0040.h5'

Hi, Thanks for sharing the code.
When I tried the sample code in: tensorflow_object_counting_api/mask_rcnn_counting_api_keras_tensorflow/barilla_spaghetti_counter_training.

I got an error"unable to open file: name = 'mask_rcnn_barilla-spaghetti_0040.h5'". I tried to look for this file, but no one was found in this repository.

How should I fix it?
Thanks

InvalidArgumentError (see above for traceback)

When I run real_time_counting.py,this error occurred:
2019-08-11 14:15:08.854541: E tensorflow/core/common_runtime/executor.cc:644] Executor failed to create kernel. Invalid argument: NodeDef mentions attr 'identical_element_shapes' not in Op<name=TensorArrayV3; signature=size:int32 -> handle:resource, flow:float; attr=dtype:type; attr=element_shape:shape,default=; attr=dynamic_size:bool,default=false; attr=clear_after_read:bool,default=true; attr=tensor_array_name:string,default=""; is_stateful=true>; NodeDef: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0". (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
[[Node: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0"]]
Traceback (most recent call last):
File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1327, in _do_call
return fn(*args)
File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1306, in _run_fn
status, run_metadata)
File "/home/lf/anaconda3/lib/python3.6/contextlib.py", line 88, in exit
next(self.gen)
File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: NodeDef mentions attr 'identical_element_shapes' not in Op<name=TensorArrayV3; signature=size:int32 -> handle:resource, flow:float; attr=dtype:type; attr=element_shape:shape,default=; attr=dynamic_size:bool,default=false; attr=clear_after_read:bool,default=true; attr=tensor_array_name:string,default=""; is_stateful=true>; NodeDef: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0". (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
[[Node: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0"]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "real_time_counting.py", line 31, in
object_counting_api.object_counting(input_video, detection_graph, category_index, is_color_recognition_enabled) # counting all the objects
File "/home/lf/桌面/tensorflow_object_counting_api/api/object_counting_api.py", line 302, in object_counting
feed_dict={image_tensor: image_np_expanded})
File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 895, in run
run_metadata_ptr)
File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1124, in _run
feed_dict_tensor, options, run_metadata)
File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1321, in _do_run
options, run_metadata)
File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1340, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: NodeDef mentions attr 'identical_element_shapes' not in Op<name=TensorArrayV3; signature=size:int32 -> handle:resource, flow:float; attr=dtype:type; attr=element_shape:shape,default=; attr=dynamic_size:bool,default=false; attr=clear_after_read:bool,default=true; attr=tensor_array_name:string,default=""; is_stateful=true>; NodeDef: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0". (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
[[Node: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0"]]

Caused by op 'Preprocessor/map/TensorArray', defined at:
File "real_time_counting.py", line 17, in
detection_graph, category_index = backbone.set_model('ssd_mobilenet_v1_coco_2018_01_28')
File "/home/lf/桌面/tensorflow_object_counting_api/utils/backbone.py", line 47, in set_model
tf.import_graph_def(od_graph_def, name='')
File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 313, in import_graph_def
op_def=op_def)
File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2630, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/home/lf/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1204, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): NodeDef mentions attr 'identical_element_shapes' not in Op<name=TensorArrayV3; signature=size:int32 -> handle:resource, flow:float; attr=dtype:type; attr=element_shape:shape,default=; attr=dynamic_size:bool,default=false; attr=clear_after_read:bool,default=true; attr=tensor_array_name:string,default=""; is_stateful=true>; NodeDef: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0". (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
[[Node: Preprocessor/map/TensorArray = TensorArrayV3clear_after_read=true, dtype=DT_FLOAT, dynamic_size=false, element_shape=, identical_element_shapes=true, tensor_array_name="", _device="/job:localhost/replica:0/task:0/cpu:0"]]
I found the error tf.import_graph_def(od_graph_def, name= "). I don't know how to correct it. Could you please help me

visualization_utils error

Hi, I'm getting this error when trying to load the API. I've installed the modified utils files and I've verified that visualization_utils.py in the utils folder has the correct function. Thanks!

AttributeError Traceback (most recent call last)
in
17 deviation = 1 # the constant that represents the object counting area
18
---> 19 object_counting_api.cumulative_object_counting_x_axis(input_video, detection_graph, category_index, is_color_recognition_enabled, fps, width, height, roi, deviation) # counting all the objects

~\AppData\Local\Programs\Python\Python37\Lib\site-packages\tensorflow\models\research\object_detection\api\object_counting_api.py in cumulative_object_counting_x_axis(input_video, detection_graph, category_index, is_color_recognition_enabled, fps, width, height, roi, deviation)
72
73 # Visualization of the results of a detection.
---> 74 counter, csv_line, counting_mode = vis_util.visualize_boxes_and_labels_on_image_array_x_axis(cap.get(1),
75 input_frame,
76 1,
AttributeError: module 'utils.visualization_utils' has no attribute 'visualize_boxes_and_labels_on_image_array_x_axis'

vehicle detection error

@ahmetozlu When I run vehicle_counting.py the bounding boxes are getting displayed on the vehicles but when it passes the ROI line its not getting detected. please help me with this

Tensorflow object counting with using C#.Net

i'm looking below requirements with C#.net
Recognition of approximate vehicle color
Detection of vehicle direction of travel
Prediction the speed of the vehicle
Prediction of approximate vehicle size
Detection of vehicle Category

how to make a target object counter like vehicle_counting.py

Now the real_time_counting_targeted_object.py counting the objects and show the total detected objects in current frame,but I wanna make a target objects counter like vehicle_counting.py in which objects are counted for whole video after crossing line.
BTW your work is great,Thanks for that.

Not able to see video of counting people

After a lot of struggle, I am able to run this project on windows 10, but I am not able to see a visualization(video) of counting of people and bicycle inside the rectangle.
Could you please help us?

I am getting out like this after running python real_time_counting.py

Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

['person: 88%']
person: 88
'person:': 1
mode1
writing frame
['person: 87%']

How to try new dataset based on my data

Hi
Using this algorithm I can able detected vehicle and color of the vehicle, but I need more information like make and model of the vehicle for that I need to train based on my dataset. Can you help me how to train dataset on this algorithm?

Variable that counts the cars

Hi, I would like to know what's the variable that counts the cars detected in the video and in which file is located.

sem titulo

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.