## 4 Overview and Development of Deep Learning Framework
### Deep Learning Framework Development
#### 4.2.1 TensorFlow, TensorFlow-Lite, TensorFlow-TensorRT  
Development 1 shows the main part of the utils.py source code for measuring the performance inference of TensorFlow, TF-Lite, and TF-TRT. ```
155 if^cocoo^in FLAGS.weights:
156 ifclass_ind==0:
157 value_0=score*100
158 elifclass_ind==2:
159 value_1=score*100
160 else:
161 continue
162 if^voc in FLAGS.weights:
163 ifclass_ind==14:
164 value_0=score*100
165 elifclass_ind==6:
166 value_1=score*100
167 else:
168 continue
```  
**Development 1. ** /core/utils.py  
In Development 1, modify the draw_bbox() function in /core/utils.py. When detecting, the object number of the predefined text file is different, so it is separated and executed according to the dataset used through the IF syntax. In the case of COCO dataset, when the person object is detected (\"0\") according to the object number of the COCO.names text file, it is stored in the value_0 variable, and when the car object (\"2\") is detected, it is stored in value_1. In the case of PASCAL VOC dataset, since the object number of the text file is different, when the person object is detected (\"14\"), it is stored in the value_0 variable, and when the car object (\"6\") is detected, it is stored in value_1. Since the accuracy has a value between 0.1 and 1, multiply by 100 (Line 155-168). The variables that store the object's accuracy are returned to the main function of detectvideo_jtop.py (Line 180). Then, copy detectvideo.py, the main source code for measuring inference performance, and create a new detectvideo_jtop.py. Development 2 shows the main part of the source code for measuring TensorFlow's performance inference. Related libraries for saving metrics generated during performance inference measurements are input (Line 15 to 17). For performance inference measurements, a DictWriter function of the csv library is added to load an image using the read() method of the VideoCapture function of the OpenCV library at the same time as the code starts, and detection starts (Line 67-78). If you input \"q\" when measuring inference performance, inference stops and calculates and outputs the average accuracy of Person and Car, framework name used, model name used, and average delay time. (Line 140-155). The following copies de-tectvideo_jtop.py, written in Development 2 to detectvideo_jtop_tflite.py for TF-Lite performance inference measurement. **Development 2. ** /detectvideo_jtop.py  
15 from jtop import jtop, JtopException  
16 import csv  
17 import argparse  
67 try:  
68 with jtop() as jetson:  
69 with open(FLAGS.csvfile, 'w') as csvfile:  
70 stats = jetson.stats  
71 writer = csv.DictWriter(csvfile, fieldnames = stats.keys())  
72 writer.writeheader()  
73 writer.writerow(stats)  
74 while True:  
75 stats = jetson.stats  
76 writer.writerow(stats)  
77 return_value, frame = vid.read()  
78... # (obmitted--it's the same as detectvideo.py)  
140 if cv2.waitKey(1) & okFF == ord('q'):  
141 del info_list[0]  
142 del info_list[1]  
143 del info_list[2]  
144 best_list_0_sum = sum(best_list_0)  
145 best_list_0_avg = best_list_0_sum/len(best_list_0)  
146 best_list_1_sum = sum(best_list_1)  
147 best_list_1_avg = best_list_1_sum/len(best_list_1)  
148 info_list_sum = sum(info_list)  
149 info_list_avg = info_list_sum/len(info_list)  
150 print(\"person average: [:.2f]\".format(best_list_0_avg))  
151 print(\"car average: [:.2f]\".format(best_list_1_avg))  
152 print(\"framework: [\(|\)\".format(FLAGS.framework))  
153 print(\"weights: \(|\)\".format(FLAGS.weights))  
154 print(\"average ms: [:-.2f]\".format(info_list_avg))  
155 break  
**Development 3** shows the main part of the source code for measuring performance inference of TF-Lite. Lines 15 to 17, Lines 67 to 78, and Lines 170 to 185 are the same as detectvideo_jtop.py. The code was modified and supplemented because the detectvideo_jtop.py created for TF-Lite performance inference measurement was executed, but a list index range error occurred and was not executed.