# car-light-dection2 **Repository Path**: matiji/car-light-dection2 ## Basic Information - **Project Name**: car-light-dection2 - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-04-10 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### start from this page ```https://github.com/tensorflow/models/tree/master/research/object_detection``` #### 0. prepare image and label image to xml #### 1. xml_to_csv.py #### 2. split_labes.py #### 3. draw_boxes.py display bounding box #### 4. generate_tfrecord.py ##### No Need From tensorflow/models/ Create train data: python generate_tfrecord.py --csv_input=data/train_labels.csv --output_path=data/train.record ##### Create test data: python generate_tfrecord.py --csv_input=data/test_labels.csv --output_path=data/test.record #### 5. confi pipline 5.1 config checkpoint ``` While optional, it is highly recommended that users utilize other object detection checkpoints. Training an object detector from scratch can take days. To speed up the training process, it is recommended that users re-use the feature extractor parameters from a pre-existing object classification or detection checkpoint. train_config provides two fields to specify pre-existing checkpoints: fine_tune_checkpoint and from_detection_checkpoint. fine_tune_checkpoint should provide a path to the pre-existing checkpoint (ie:"/usr/home/username/checkpoint/model.ckpt-#####"). # from_detection_checkpoint is a boolean value. If false, it assumes the checkpoint was from an object classification checkpoint. Note that starting from a detection checkpoint will usually result in a faster training job than a classification checkpoint. ``` fine_tune_checkpoint: "/usr/home/username/tmp/model.ckpt-#####" from_detection_checkpoint: true 5.2 config train_input_reader ``` train_input_reader: { tf_record_input_reader { input_path: "../data/train.record" } label_map_path: "../data/light_label_map.pbtxt" } eval_config: { num_examples: 40 } ``` 5.3 config eval_input_reader eval_input_reader: { tf_record_input_reader { input_path: "../data/test.record" } label_map_path: "../data/light_label_map.pbtxt" shuffle: false num_readers: 1 } #### 6. train data #### running locally https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/running_locally.md ``` python train.py --train_dir='/home/shz/TF-OD-Test/train' --pipeline_config_path='/home/shz/TF-OD-Test/models/ssd_mobilenet/ssd_mobilenet_v1_pascal.config' ``` #### 7. eval model from checkpoint #### 8. Exporting a trained model for inference After your model has been trained, you should export it to a Tensorflow graph proto. A checkpoint will typically consist of three files: model download url : base url ```http://download.tensorflow.org/models/object_detection/``` example utl ```http://download.tensorflow.org/models/object_detection/faster_rcnn_nas_coco_2017_11_08.tar.gz``` model.ckpt-${CHECKPOINT_NUMBER}.data-00000-of-00001, model.ckpt-${CHECKPOINT_NUMBER}.index model.ckpt-${CHECKPOINT_NUMBER}.meta After you've identified a candidate checkpoint to export, run the following command from tensorflow/models/research: ##### From tensorflow/models/research/ TRAIN_PATH=light_detection/models/model/train PIPELINE_CONFIG_PATH=light_detection/models/model/ssd_mobilenet_v1_pets.config python object_detection/export_inference_graph.py \ --input_type image_tensor \ --pipeline_config_path ${PIPELINE_CONFIG_PATH} \ --trained_checkpoint_prefix ${TRAIN_PATH}/model.ckpt-9159 \ --output_directory ${TRAIN_PATH}/output_inference_graph.pb ##### example : python object_detection/export_inference_graph.py \ --input_type image_tensor \ --pipeline_config_path ${PIPELINE_CONFIG_PATH} \ --trained_checkpoint_prefix ${TRAIN_PATH}/model.ckpt-9159 \ --output_directory ${TRAIN_PATH}/output_inference_graph.pb Afterwards, you should see a graph named output_inference_graph.pb. # make sure which object_detection module do you use before change # object_detection\core\losses.py 301 self._logit_scale = tf.cast(self._logit_scale, tf.float32) # TODO change : Add cast to float to avoid devid error # object_detection\utils\learning_schedules.py 153 tf.constant(list(range(num_boundaries)), dtype=tf.int32),