EXAMPLE:
FUNCTION:
DESCRIPTION:
The Main interface and program entrance. There are two import data structures used in this module. The Input_Queue and Output_Queue.
The Module contains a while loop runs in main thread.
The Input_Queue is feed with the input image (with a form of np.array) by VideoStream().read(). As a FIFO Queue, the image array en-queued will be extracted by Worker(..) running in a number of sub-threads.
Worker(..) will extract the image and load the pre-trained model (in a form of TensorFlow Graph). It creates TensorFlow Session and passes the session, graph along with the image to Detect(...). After obtained the return value (a modified image with labels and boxes in a form of np.array), Worker() will put it to Output_Queue.
Detect(..), will extract each output tensor object in past graph and fetch the value of them. Then it calls vis_util.visualize_boxes_and_labels(..) to add corresponding value to the image array. Then return it.
The main thread will then extract the frame in Output_Queue and display it by using API provided by OpenCV.
CLASS:
FUNCTION:
DESCRIPTION:
This module serves as an auxiliary tool to support the real-time object recognition purpose.
The FPS class provides capability of calculating the value of frame per second during the operation of the program which will be a criterion of the program.
The VideoStream class is capable of capturing video input from designated input source which is not confined to camera input. It is also able to extract single frame and hand it to the recognition module.
The stand alone function color_name_to_rgb will convert the matplot.colors to dictionary. It also transforms the hex value of color to three 8-bit RGB values.
The draw_boxes_and_labels function creates boxes and labels of recognized object. The return value consists of coordination, classes and colors that will be visualized later.
FUNCTION:
DESCRIPTION:
This module is used to convert batch of XML files into one CSV file. In accordance to the requirement of TensorFlow Object Detection API, the following features should be provided in the CSV file:
1. Filename: the file name of the original images
2. The width of the image
3. The height of the image
4. The corresponding Class of the image
5. The coordination of the rectangular labeled object (xmin, ymin, xmax, ymax)
Example:
filename width height class xmin ymin xmax ymax
dog_image.jpg 256 256 dog 0 10 200 100
DESCRIPTION:
A pure scripting python file, used to separate training data and test data from the original dataset. The percentage of the training data can be adjusted according to command line input.
Example:
python CSVSpliter -s [original source csv file] -p [percentage of training data]
return train_labesl.csv and test_labels.csv.
These two files should be transformed to corresponding .tfrecord format files in accordance to the TensorFlow requirement
EXAMPLE: Create train data:
python generate_tfrecord.py --csv_input --output_path
Create test data:
python generate_tfrecord.py --csv_input --output_path
DESCRIPTION:
TensorFlow requires the dataset to be stored in a specific format called TFRecord. A TFRecord combines all the labels (bounding boxes) and images for the entire dataset into one file. Thus it is very convenience to use. This module is meant to be used as a converter which will transform the corresponding CSV file and images to TFRecord.
DESCRIPTION:
EXAMPLE: python train.py \
--logtostderr \
--train_dir=path/to/train_dir \
--pipeline_config_path=pipeline_config.pbtxt
DESCRIPTION:
EXAMPLE:
python export_inference_graph \
--input_type image_tensor \
--pipeline_config_path path/to/ssd_inception_v2.config \
--trained_checkpoint_prefix path/to/model.ckpt \
--output_directory path/to/exported_model_directory
DESCRIPTION:
1. Image_tensor: this kind of input accepts a uint8 4-D tensor of shape [None, None, None,3].
2. Encoded_image_string_tensor: Accept 1-D string tensor.
3. tf_example