تجاوز إلى المحتوى الرئيسي
User Image

Dr Mohamed Abdelkader Bencherif

Assistant Professor

Researcher

علوم الحاسب والمعلومات
B31/G108
مدونة

Working With tensorFlow and tensorBoard

Thos blog will present some material to work on tensorflow and tensorboard in object detection, inclusing shape detection and gesture recognition.
https://www.tensorflow.org/

Steps to Go:
1. Install tensorflow from https://www.tensorflow.org/install/
2. Depending on you application, download from the pretrained deep models the model that fits you application, see the list here , some models were trained on the COCO dataset
3. One the model dowloaded, and depending on the tensorflow version and the number of classes, you need to adjust the your_model.config file (paths to the checkpoint models and the number of classes).
this is done through an export in a one line statement :

python3 export_inference_graph.py \
--input_type image_tensor \
--pipeline_config_path training/your_model.config \
--trained_checkpoint_prefix training/model.ckpt-last_big_number \
--output_directory the_new-graph

5. Once the frozen model is exported,you need to retrain the model for the new class, this is done by collecting a set of images : train/many_images and test/some_images
with a train.csv and test.csv labels files.
The format of the train.csv and test.csv follows the pattren : (for instance):
filename,width,height,class,xmin,ymin,xmax,ymax
PUZZLE_LIVINGROOM_H_S_frame_1615.jpg,1280,720,hand,262,39,516,218

6. The next step is to create a tf.record for train and a tf.record for test
this is done by :

python3 generate_tfrecord.py --csv_input=data/train_labels.csv --output_path=data/train.record

python3 generate_tfrecord.py --csv_input=data/test_labels.csv --output_path=data/test.record
NB: be careful here, the images must be visible to this python script,  as it reads frames and converts them to a tf.record.

7. train your model (use the python notebook object-detection.ipynb from https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb
(You can convert to a python modele to use in spyder)

8. test you model, through passing some test images.
9. if you need to work on online detection, you need to have opencv installed , else install it following this tutorial : https://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/
10. Modify the python (previous notebook), by removing any matplotlib online and plt of PIL  library.
11. use cv2.Videocapture(0) , for a webcam + all cv2.stuff
12. Enjoy realtime.