Comments (9)
Hmmm ...
That is indeed baffling - 1fps.
Just for sanity ... to ensure its not some issue with the handtracking code (or differences in implementation environment like #3 #5 and #6), it may be a good idea to compare this with the speed you achieve for the basic tensorflow object detection api tutorial. Similar FPS might suggest your development environment (CPU) as the reason for the slow speed.
One more thing, my test environment is a MacbookPro i7, 2.5GHz, 16GB Quad Core. I also have compiled Tensorflow from source to ensure it is optimized for my cpu architecture (which makes tensorflow faster).
For other ways to optimize tensorflow, I think this link may be helpful.
https://www.tensorflow.org/performance/performance_guide
-V.
from handtracking.
@victordibia Have you applied NMS to merge repeated bounding box? If you do that I think it may make a better performance in detection.
from handtracking.
Happy to try it out.
What do you mean by NMS though? Any link you can share that describes it in more detail?
-V.
from handtracking.
@victordibia
this video may help you to understand NMS.
Here is some python code to implement it:
import sys
from operator import itemgetter
import numpy as np
import cv2
'''
Function:
calculate Intersect of Union
Input:
rect_1: 1st rectangle
rect_2: 2nd rectangle
Output:
IoU
'''
def IoU(rect_1, rect_2):
x11 = rect_1[0] # first rectangle top left x
y11 = rect_1[1] # first rectangle top left y
x12 = rect_1[2] # first rectangle bottom right x
y12 = rect_1[3] # first rectangle bottom right y
x21 = rect_2[0] # second rectangle top left x
y21 = rect_2[1] # second rectangle top left y
x22 = rect_2[2] # second rectangle bottom right x
y22 = rect_2[3] # second rectangle bottom right y
x_overlap = max(0, min(x12,x22) -max(x11,x21))
y_overlap = max(0, min(y12,y22) -max(y11,y21))
intersection = x_overlap * y_overlap
union = (x12-x11) * (y12-y11) + (x22-x21) * (y22-y21) - intersection
if union == 0:
return 0
else:
return float(intersection) / union
'''
Function:
calculate Intersect of Min area
Input:
rect_1: 1st rectangle
rect_2: 2nd rectangle
Output:
IoM
'''
def IoM(rect_1, rect_2):
x11 = rect_1[0] # first rectangle top left x
y11 = rect_1[1] # first rectangle top left y
x12 = rect_1[2] # first rectangle bottom right x
y12 = rect_1[3] # first rectangle bottom right y
x21 = rect_2[0] # second rectangle top left x
y21 = rect_2[1] # second rectangle top left y
x22 = rect_2[2] # second rectangle bottom right x
y22 = rect_2[3] # second rectangle bottom right y
x_overlap = max(0, min(x12,x22) -max(x11,x21))
y_overlap = max(0, min(y12,y22) -max(y11,y21))
intersection = x_overlap * y_overlap
rect1_area = (y12 - y11) * (x12 - x11)
rect2_area = (y22 - y21) * (x22 - x21)
min_area = min(rect1_area, rect2_area)
return float(intersection) / min_area
'''
Function:
apply NMS(non-maximum suppression) on ROIs in same scale
Input:
rectangles: rectangles[i][0:3] is the position, rectangles[i][4] is scale, rectangles[i][5] is score
Output:
rectangles: same as input
'''
def NMS(rectangles,threshold,type):
sorted(rectangles,key=itemgetter(4),reverse=True)
result_rectangles = rectangles
number_of_rects = len(result_rectangles)
cur_rect = 0
while cur_rect < number_of_rects :
rects_to_compare = number_of_rects - cur_rect - 1
cur_rect_to_compare = cur_rect + 1
while rects_to_compare > 0:
score = 0
if type == 'iou':
score = IoU(result_rectangles[cur_rect], result_rectangles[cur_rect_to_compare])
else:
score = IoM(result_rectangles[cur_rect], result_rectangles[cur_rect_to_compare])
if score >= threshold:
del result_rectangles[cur_rect_to_compare] # delete the rectangle
number_of_rects -= 1
else:
cur_rect_to_compare += 1 # skip to next rectangle
rects_to_compare -= 1
cur_rect += 1 # finished comparing for current rectangle
return result_rectangles
from handtracking.
@victordibia In original repo, weiliu89 has applied NMS with a threshold of 0.45. you can find it in ssd_pascal.py
.
# parameters for generating detection output.
det_out_param = {
'num_classes': num_classes,
'share_location': share_location,
'background_label_id': background_label_id,
'nms_param': {'nms_threshold': 0.45, 'top_k': 400},
'keep_top_k': 200,
'confidence_threshold': 0.01,
'code_type': code_type,
}
from handtracking.
@Hzzone , thanks for the link, will look through it and post any updates I find.
Btw ... I am using some form of thresholding (variable score_thresh
in detect_multi_threaded.py
) already.
-V.
from handtracking.
I just cloned your repo and run the detect_multi_threaded.py
on my macbook pro (i7 2.4G, 16GB RAM). The max fps I got is just 3. Any idea to improve it?
from handtracking.
from handtracking.
I tried SSD detector (VGG16 as base) with dlib tracker for passenger counting and it disprove the saying on papers that "SSD is very fast" it shows me FPS = 0.... do you have any idea how can I make it fast to the extent that it can be used for real time passenger counting ..
from handtracking.
Related Issues (20)
- How can I detect hands in Jpg?(panel disappeared & size) HOT 1
- Just sending a note HOT 1
- why some label is not correct?
- Problem while training: zero mAp. HOT 2
- Threading to "improve" visual performance HOT 2
- Help Needed to convert the frozen graph to Tensorflow lite model HOT 4
- Problem with egohands_dataset_clean.py HOT 4
- hand detection
- Is the coordinate position of the detection box upper left corner, lower right corner or upper left corner with width and height?
- How can I use this model in Keras?
- Confusion while generating tf records
- question about frozen_inference_graph.pb
- Oxford hand dataset
- Using the savedmodel in this project for transfer learning in Keras
- Tensorflow Lite-Mobile HOT 3
- Loaded runtime CuDNN library: 7.4.2 but source was compiled with: 7.6.0 HOT 1
- Step-By-Step Tutorial and Requirements
- What's version of tensorflow was used to train model? HOT 1
- How to modify for a url stream?
- How can i use my own model for hand gestures
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from handtracking.