forked from ahmetozlu/tensorflow_object_counting_api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
single_image_object_counting.py
executable file
·23 lines (16 loc) · 1.07 KB
/
single_image_object_counting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#----------------------------------------------
#--- Author : Ahmet Ozlu
#--- Mail : [email protected]
#--- Date : 27th January 2018
#----------------------------------------------
# Imports
import tensorflow as tf
# Object detection imports
from utils import backbone
from api import object_counting_api
input_video = "./input_images_and_videos/sample_input_image.jpg"
# By default I use an "SSD with Mobilenet" model here. See the detection model zoo (https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md) for a list of other models that can be run out-of-the-box with varying speeds and accuracies.
detection_graph, category_index = backbone.set_model('ssd_mobilenet_v1_coco_2018_01_28', 'mscoco_label_map.pbtxt')
is_color_recognition_enabled = False # set it to true for enabling the color prediction for the detected objects
result = object_counting_api.single_image_object_counting(input_video, detection_graph, category_index, is_color_recognition_enabled) # targeted objects counting
print (result)