Skip to content

Add-on implementation for Tensorflow object detection. Summary table will be displayed at the right upper corner of the inference image.

License

Notifications You must be signed in to change notification settings

boguss1225/tensorflow-summary-box-addon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tensorflow add-on summary box

Introduction

Add-on implementation for Tensorflow object detection. Summary table will be displayed at the right top corner of the inference image. Also, this add-on enable to save details of detection data (class, score(%), xmin, ymin, xmax, ymax) in csv format on the inference run. The fontsize can either be assigned manually in the code (visualization_utils.py) or adjusted automatically based on the screen width (see line :1128). This add-on will be useful to capture the summarized overview of the object detection at a glance. 😼

picture

How to Apply

  1. After cloning this repo, replace the following files.
  • models/research/object_detection/utils/visualization_utils.py
  • models/research/object_detection/Object_detection_image_tf2.py
  1. install & reload dependencies
pip install tabulate=0.9.0
cd models/research/
python -m pip install .

How to run

Configure Object_detection_image_tf2.py file before run.

# Number of classes the object detector can identify
NUM_CLASSES = 20

# IMAGE_NAME
IMAGE_NAME = 'targe_image1.jpg'
# IMAGE_SAVE_NAME
IMAGE_SAVE_NAME = 'targe_image1_result'

# Path to frozen detection graph .pb file, which contains the model that is used
# for object detection.
PATH_TO_PB = '/PATH/TO/BE/CONFIGURED/PB_folder/saved_model'
# Path to label map file
PATH_TO_LABELS = '/PATH/TO/BE/CONFIGURED/labelmap.pbtxt'
# Path to image
PATH_TO_IMAGE_DIR = '/PATH/TO/test_dir'
PATH_TO_IMAGE = os.path.join(PATH_TO_IMAGE_DIR,IMAGE_NAME)

Run Object_detection_image_tf2.py under models/research/object_detection/

python Object_detection_image_tf2.py

If you want to specify GPU

export CUDA_VISIBLE_DEVICES=0 && python Object_detection_image_tf2.py

If you want to adjust the table format

Edit header at Line:1140

  headers=["Class              ", "total%", "  Qty  "]

Or edit multiplier of auto fontsize

    Summary_FontSIZE = int(im_width * 0.05)

if you want to change font color and size

Edit values at Line:47~50 of visualization_utils.py

# Set config for summary box (HM)
FontSIZE = 10
Auto_Fontsize=True
Summary_FontSIZE = 20
FontColor = 'white'

Debug

  • If font size is not working, that might be case matter.. "a"rial
# use whatever works
font = ImageFont.truetype('Arial.ttf', Summary_FontSIZE)
font = ImageFont.truetype(‘arial.ttf', Summary_FontSIZE)

Reference

About

Add-on implementation for Tensorflow object detection. Summary table will be displayed at the right upper corner of the inference image.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages