├── .gitattributes
├── .idea
├── RoadDamageDetection-DeepLearning.iml
├── modules.xml
├── vcs.xml
└── workspace.xml
├── README.md
├── Tensorflow
├── scripts
│ └── preprocessing
│ │ ├── generate_tfrecord.py
│ │ ├── rd-main.py
│ │ └── xml_to_csv.py
└── workspace
│ └── training_demo
│ ├── annotations
│ └── label_map.pbtxt
│ ├── export_inference_graph.py
│ ├── train.py
│ └── training
│ └── pipeline.config
├── komutlar.txt
├── ssd-inception-v2-config.txt
└── trainedModels
├── crack_label_map.pbtxt
└── frozen_inference_graph.pb
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.idea/RoadDamageDetection-DeepLearning.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 | 1564043503598
161 |
162 |
163 | 1564043503598
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RoadDamageDetection-DeepLearning
2 | It is intended to detect damage to road images taken by a camera. For this, deep learning technology, a subspace of machine learning, and Convolutional Neural Networks (CNN), one of the most popular types of deep neural networks, are used. The TensorFlow library is trained through the Ssd Inception V2 Coco pre-trained model to detect damage to images. As a result of the tests and trainings, the closest determinations are 86%. In order to increase the accuracy of the training, the use of GPU, the magnification of the data set and the number of iterations were considered.
3 |
4 | ## Stages Of The Project
5 | * Project Architect
6 | * Creating a DataSet
7 | * Creating LabelMap
8 | * Creating a TensorFlow Records File
9 | * Training Pipeline Configuration
10 | * Software and Features Required for Training
11 | * Training Process
12 | * Using TensorBoard for Visualization
13 | * Comparison of Different Models
14 |
15 | ## Project Architect
16 |
17 | 
18 |
19 | ## Creating a DataSet
20 |
21 | Please pay attention to the disk capacity when downloading.
22 |
23 | * [trainedModels (70MB)](https://s3-ap-northeast-1.amazonaws.com/mycityreport/trainedModels.tar.gz)
24 | * [RoadDamageDataset_v1 (1.7GB)](https://s3-ap-northeast-1.amazonaws.com/mycityreport/RoadDamageDataset.tar.gz)
25 |
26 | ## Creating LabelMap
27 |
28 | 
29 |
30 | *Xml Output of Tagged Image:*
31 |
32 | 
33 |
34 | ## Creating a TensorFlow Records File
35 |
36 | 
37 |
38 | After the tagging of the images to be used for the Train and Test stages, TFRecords, which serve as input data to the TensorFlow training model, are created.
39 | The TFRecord format is a simple format for storing a series of binary records. Protocol buffers are a cross-platform, interlingual library for efficient serialization of structured data.
40 |
41 | ## Training Pipeline Configuration
42 |
43 | The Following Config file must edit root path.
44 |
45 | ```
46 | # SSD with Inception v2 configuration for MSCOCO Dataset.
47 | # Users should configure the fine_tune_checkpoint field in the train config as
48 | # well as the label_map_path and input_path fields in the train_input_reader and
49 | # eval_input_reader. Search for "PATH_TO_BE_CONFIGURED" to find the fields that
50 | # should be configured.
51 |
52 | model {
53 | ssd {
54 | num_classes: 8 # Set this to the number of different label classes
55 | box_coder {
56 | faster_rcnn_box_coder {
57 | y_scale: 10.0
58 | x_scale: 10.0
59 | height_scale: 5.0
60 | width_scale: 5.0
61 | }
62 | }
63 | matcher {
64 | argmax_matcher {
65 | matched_threshold: 0.5
66 | unmatched_threshold: 0.5
67 | ignore_thresholds: false
68 | negatives_lower_than_unmatched: true
69 | force_match_for_each_row: true
70 | }
71 | }
72 | similarity_calculator {
73 | iou_similarity {
74 | }
75 | }
76 | anchor_generator {
77 | ssd_anchor_generator {
78 | num_layers: 6
79 | min_scale: 0.2
80 | max_scale: 0.95
81 | aspect_ratios: 1.0
82 | aspect_ratios: 2.0
83 | aspect_ratios: 0.5
84 | aspect_ratios: 3.0
85 | aspect_ratios: 0.3333
86 | reduce_boxes_in_lowest_layer: true
87 | }
88 | }
89 | image_resizer {
90 | fixed_shape_resizer {
91 | height: 300
92 | width: 300
93 | }
94 | }
95 | box_predictor {
96 | convolutional_box_predictor {
97 | min_depth: 0
98 | max_depth: 0
99 | num_layers_before_predictor: 0
100 | use_dropout: false
101 | dropout_keep_probability: 0.8
102 | kernel_size: 3
103 | box_code_size: 4
104 | apply_sigmoid_to_scores: false
105 | conv_hyperparams {
106 | activation: RELU_6,
107 | regularizer {
108 | l2_regularizer {
109 | weight: 0.00004
110 | }
111 | }
112 | initializer {
113 | truncated_normal_initializer {
114 | stddev: 0.03
115 | mean: 0.0
116 | }
117 | }
118 | }
119 | }
120 | }
121 | feature_extractor {
122 | type: 'ssd_inception_v2' # Set to the name of your chosen pre-trained model
123 | min_depth: 16
124 | depth_multiplier: 1.0
125 | conv_hyperparams {
126 | activation: RELU_6,
127 | regularizer {
128 | l2_regularizer {
129 | weight: 0.00004
130 | }
131 | }
132 | initializer {
133 | truncated_normal_initializer {
134 | stddev: 0.03
135 | mean: 0.0
136 | }
137 | }
138 | batch_norm {
139 | train: true,
140 | scale: true,
141 | center: true,
142 | decay: 0.9997,
143 | epsilon: 0.001,
144 | }
145 | }
146 | override_base_feature_extractor_hyperparams: true
147 | }
148 | loss {
149 | classification_loss {
150 | weighted_sigmoid {
151 | }
152 | }
153 | localization_loss {
154 | weighted_smooth_l1 {
155 | }
156 | }
157 | hard_example_miner {
158 | num_hard_examples: 3000
159 | iou_threshold: 0.99
160 | loss_type: CLASSIFICATION
161 | max_negatives_per_positive: 3
162 | min_negatives_per_image: 0
163 | }
164 | classification_weight: 1.0
165 | localization_weight: 1.0
166 | }
167 | normalize_loss_by_num_matches: true
168 | post_processing {
169 | batch_non_max_suppression {
170 | score_threshold: 1e-8
171 | iou_threshold: 0.6
172 | max_detections_per_class: 100
173 | max_total_detections: 100
174 | }
175 | score_converter: SIGMOID
176 | }
177 | }
178 | }
179 |
180 | train_config: {
181 | batch_size: 12 # Increase/Decrease this value depending on the available memory (Higher values require more memory and vice-versa)
182 | optimizer {
183 | rms_prop_optimizer: {
184 | learning_rate: {
185 | exponential_decay_learning_rate {
186 | initial_learning_rate: 0.004
187 | decay_steps: 800720
188 | decay_factor: 0.95
189 | }
190 | }
191 | momentum_optimizer_value: 0.9
192 | decay: 0.9
193 | epsilon: 1.0
194 | }
195 | }
196 | fine_tune_checkpoint: "|Enter the root path|/Tensorflow/workspace/training_demo/pre-trained-model/model.ckpt" # Path to extracted files of pre-trained model
197 | from_detection_checkpoint: true
198 | # Note: The below line limits the training process to 200K steps, which we
199 | # empirically found to be sufficient enough to train the pets dataset. This
200 | # effectively bypasses the learning rate schedule (the learning rate will
201 | # never decay). Remove the below line to train indefinitely.
202 | num_steps: 200000
203 | data_augmentation_options {
204 | random_horizontal_flip {
205 | }
206 | }
207 | data_augmentation_options {
208 | ssd_random_crop {
209 | }
210 | }
211 | }
212 |
213 | train_input_reader: {
214 | tf_record_input_reader {
215 | input_path: "|Enter the root path|/Tensorflow/workspace/training_demo/annotations/train.record" # Path to training TFRecord file
216 | }
217 | label_map_path: "|Enter the root path|/Tensorflow/workspace/training_demo/annotations/label_map.pbtxt" # Path to label map file
218 | }
219 |
220 | eval_config: {
221 | num_examples: 8000
222 | # Note: The below line limits the evaluation process to 10 evaluations.
223 | # Remove the below line to evaluate indefinitely.
224 | max_evals: 10
225 | }
226 |
227 | eval_input_reader: {
228 | tf_record_input_reader {
229 | input_path: "|Enter the root path|/Tensorflow/workspace/training_demo/annotations/test.record" # Path to testing TFRecord
230 | }
231 | label_map_path: "|Enter the root path|/Tensorflow/workspace/training_demo/annotations/label_map.pbtxt" # Path to label map file
232 | shuffle: false
233 | num_readers: 1
234 | }
235 | ```
236 |
237 | ## Software and Features Required for Training
238 |
239 | 
240 |
241 | ## Training Process
242 |
243 | Execute on Python Command Line the following code.
244 |
245 | 
246 |
247 | The result will look like this:
248 |
249 | 
250 |
251 | ## Using TensorBoard for Visualization
252 |
253 | 
254 |
255 | ## Test Result
256 |
257 | 
258 |
259 | 
260 |
261 | 
262 |
263 | **PROJECT END**
264 | ---
265 |
266 | > If you have any problems, please contact me via the links [LinkedIn (Ertuğrul Kuran)](https://www.linkedin.com/in/ertkrn/)
267 |
268 | > Email Address: ertkrn@hotmail.com
269 |
--------------------------------------------------------------------------------
/Tensorflow/scripts/preprocessing/generate_tfrecord.py:
--------------------------------------------------------------------------------
1 | from __future__ import division
2 | from __future__ import print_function
3 | from __future__ import absolute_import
4 |
5 | import os
6 | import io
7 | import pandas as pd
8 | import tensorflow as tf
9 | import sys
10 | parentdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
11 | parentdir = os.path.abspath(os.path.join(parentdir, '..'))
12 |
13 | sys.path.append(parentdir + '/models/research/')
14 |
15 | from PIL import Image
16 | from object_detection.utils import dataset_util
17 | #from object_detection.utils import label_map_util
18 |
19 | #from object_detection.utils import visualization_utils as vis_util
20 | from collections import namedtuple, OrderedDict
21 |
22 | flags = tf.app.flags
23 | flags.DEFINE_string('csv_input', '', 'Path to the CSV input')
24 | flags.DEFINE_string('output_path', '', 'Path to output TFRecord')
25 | flags.DEFINE_string('label0', '', 'Name of class label')
26 | flags.DEFINE_string('label1', '', 'Name of class label')
27 | flags.DEFINE_string('label2', '', 'Name of class label')
28 | flags.DEFINE_string('label3', '', 'Name of class label')
29 | flags.DEFINE_string('label4', '', 'Name of class label')
30 | flags.DEFINE_string('label5', '', 'Name of class label')
31 | flags.DEFINE_string('label6', '', 'Name of class label')
32 | flags.DEFINE_string('label7', '', 'Name of class label')
33 | # if your image has more labels input them as
34 | # flags.DEFINE_string('label0', '', 'Name of class[0] label')
35 | # flags.DEFINE_string('label1', '', 'Name of class[1] label')
36 | # and so on.
37 | flags.DEFINE_string('img_path', '', 'Path to images')
38 | FLAGS = flags.FLAGS
39 |
40 |
41 | # TO-DO replace this with label map
42 | # for multiple labels add more else if statements
43 | def class_text_to_int(row_label):
44 | print(row_label)
45 | #if row_label == FLAGS.label: # 'ship':
46 | # return 1
47 | # comment upper if statement and uncomment these statements for multiple labelling
48 | if row_label == FLAGS.label0:
49 | return 1
50 | elif row_label == FLAGS.label1:
51 | return 2
52 | elif row_label == FLAGS.label2:
53 | return 3
54 | elif row_label == FLAGS.label3:
55 | return 4
56 | elif row_label == FLAGS.label4:
57 | return 5
58 | elif row_label == FLAGS.label5:
59 | return 6
60 | elif row_label == FLAGS.label6:
61 | return 7
62 | elif row_label == FLAGS.label7:
63 | return 8
64 | else:
65 | None
66 |
67 |
68 | def split(df, group):
69 | data = namedtuple('data', ['filename', 'object'])
70 | gb = df.groupby(group)
71 | return [data(filename, gb.get_group(x)) for filename, x in zip(gb.groups.keys(), gb.groups)]
72 |
73 |
74 | def create_tf_example(group, path):
75 | with tf.gfile.GFile(os.path.join(path, '{}'.format(group.filename)), 'rb') as fid:
76 | encoded_jpg = fid.read()
77 | encoded_jpg_io = io.BytesIO(encoded_jpg)
78 | image = Image.open(encoded_jpg_io)
79 | width, height = image.size
80 |
81 | filename = group.filename.encode('utf8')
82 | image_format = b'jpg'
83 | # check if the image format is matching with your images.
84 | xmins = []
85 | xmaxs = []
86 | ymins = []
87 | ymaxs = []
88 | classes_text = []
89 | classes = []
90 |
91 | for index, row in group.object.iterrows():
92 | xmins.append(row['xmin'] / width)
93 | xmaxs.append(row['xmax'] / width)
94 | ymins.append(row['ymin'] / height)
95 | ymaxs.append(row['ymax'] / height)
96 | classes_text.append(row['class'].encode('utf8'))
97 | classes.append(class_text_to_int(row['class']))
98 |
99 | tf_example = tf.train.Example(features=tf.train.Features(feature={
100 | 'image/height': dataset_util.int64_feature(height),
101 | 'image/width': dataset_util.int64_feature(width),
102 | 'image/filename': dataset_util.bytes_feature(filename),
103 | 'image/source_id': dataset_util.bytes_feature(filename),
104 | 'image/encoded': dataset_util.bytes_feature(encoded_jpg),
105 | 'image/format': dataset_util.bytes_feature(image_format),
106 | 'image/object/bbox/xmin': dataset_util.float_list_feature(xmins),
107 | 'image/object/bbox/xmax': dataset_util.float_list_feature(xmaxs),
108 | 'image/object/bbox/ymin': dataset_util.float_list_feature(ymins),
109 | 'image/object/bbox/ymax': dataset_util.float_list_feature(ymaxs),
110 | 'image/object/class/text': dataset_util.bytes_list_feature(classes_text),
111 | 'image/object/class/label': dataset_util.int64_list_feature(classes),
112 | }))
113 | return tf_example
114 |
115 |
116 | def main(_):
117 | writer = tf.python_io.TFRecordWriter(FLAGS.output_path)
118 | path = os.path.join(os.getcwd(), FLAGS.img_path)
119 | examples = pd.read_csv(FLAGS.csv_input, engine='python')
120 | grouped = split(examples, 'filename')
121 | for group in grouped:
122 | print(group)
123 | tf_example = create_tf_example(group, path)
124 | writer.write(tf_example.SerializeToString())
125 |
126 | writer.close()
127 | output_path = os.path.join(os.getcwd(), FLAGS.output_path)
128 | print('Successfully created the TFRecords: {}'.format(output_path))
129 |
130 |
131 | if __name__ == '__main__':
132 | tf.app.run()
--------------------------------------------------------------------------------
/Tensorflow/scripts/preprocessing/rd-main.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import sys
3 | import os
4 | import tarfile
5 | import tensorflow as tf
6 | import zipfile
7 | import cv2
8 | import random
9 |
10 | from collections import defaultdict
11 | from io import StringIO
12 | from matplotlib import pyplot as plt
13 | from PIL import Image
14 |
15 | parentpath = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
16 | parentpath = os.path.abspath(os.path.join(parentpath, '..'))
17 |
18 | sys.path.append(parentpath + '/models/research/')
19 |
20 |
21 | from object_detection.utils import label_map_util
22 |
23 | from object_detection.utils import visualization_utils as vis_util
24 |
25 |
26 | parentdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
27 | parentdir = os.path.abspath(os.path.join(parentdir, '..'))
28 | parentdir = os.path.abspath(os.path.join(parentdir, '..'))
29 | parentdir = parentdir + '/trainedModels/'
30 |
31 | flags = tf.app.flags
32 | flags.DEFINE_string('path_to_image', '',
33 | 'Path to a image '
34 | 'file. If provided, other configs are ignored')
35 |
36 | FLAGS = flags.FLAGS
37 |
38 |
39 | PATH_TO_CKPT = parentdir + 'frozen_inference_graph.pb'
40 | #PATH_TO_CKPT = parentdir + 'ilkEgitim/frozen_inference_graph.pb'
41 | PATH_TO_LABELS = parentdir + 'crack_label_map.pbtxt'
42 | NUM_CLASSES = 8
43 |
44 | detection_graph = tf.Graph()
45 | with detection_graph.as_default():
46 | od_graph_def = tf.GraphDef()
47 | with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
48 | serialized_graph = fid.read()
49 | od_graph_def.ParseFromString(serialized_graph)
50 | tf.import_graph_def(od_graph_def, name='')
51 |
52 | label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
53 | categories = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES, use_display_name=True)
54 | category_index = label_map_util.create_category_index(categories)
55 |
56 | def load_image_into_numpy_array(image):
57 | (im_width, im_height) = image.size
58 | return np.array(image.getdata()).reshape(
59 | (im_height, im_width, 3)).astype(np.uint8)
60 |
61 | parentdir = os.path.abspath(os.path.join(parentdir, '..'))
62 | base_path = parentdir + '/RoadDamageDataset/'
63 | # get images from val.txt
64 | PATH_TO_TEST_IMAGES_DIR = base_path
65 | D_TYPE = ['D00', 'D01', 'D10', 'D11', 'D20','D40', 'D43']
66 | govs = ['Adachi', 'Ichihara', 'Muroran', 'Chiba', 'Sumida', 'Nagakute', 'Numazu']
67 |
68 | val_list = []
69 | for gov in govs:
70 | file = open(PATH_TO_TEST_IMAGES_DIR + gov + '/ImageSets/Main/val.txt', 'r')
71 | for line in file:
72 | line = line.rstrip('\n').split('/')[-1]
73 | val_list.append(line)
74 | file.close()
75 |
76 | print("# of validation images:" + str(len(val_list)))
77 |
78 | TEST_IMAGE_PATHS=[]
79 | random.shuffle(val_list)
80 |
81 | test_path = "" #input a test image path
82 | if FLAGS.path_to_image:
83 | test_path = FLAGS.path_to_image
84 | else:
85 | test_path = "" #input a test image path
86 | TEST_IMAGE_PATHS.append(test_path)
87 | # Size, in inches, of the output images.
88 | IMAGE_SIZE = (12, 8)
89 |
90 | with detection_graph.as_default():
91 | with tf.Session(graph=detection_graph) as sess:
92 | # Definite input and output Tensors for detection_graph
93 | image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')
94 | # Each box represents a part of the image where a particular object was detected.
95 | detection_boxes = detection_graph.get_tensor_by_name('detection_boxes:0')
96 | # Each score represent how level of confidence for each of the objects.
97 | # Score is shown on the result image, together with the class label.
98 | detection_scores = detection_graph.get_tensor_by_name('detection_scores:0')
99 | detection_classes = detection_graph.get_tensor_by_name('detection_classes:0')
100 | num_detections = detection_graph.get_tensor_by_name('num_detections:0')
101 | for image_path in TEST_IMAGE_PATHS:
102 | image = Image.open(image_path)
103 | # the array based representation of the image will be used later in order to prepare the
104 | # result image with boxes and labels on it.
105 | image_np = load_image_into_numpy_array(image)
106 | # Expand dimensions since the model expects images to have shape: [1, None, None, 3]
107 | image_np_expanded = np.expand_dims(image_np, axis=0)
108 | # Actual detection.
109 | (boxes, scores, classes, num) = sess.run(
110 | [detection_boxes, detection_scores, detection_classes, num_detections],
111 | feed_dict={image_tensor: image_np_expanded})
112 | # Visualization of the results of a detection.
113 | vis_util.visualize_boxes_and_labels_on_image_array(
114 | image_np,
115 | np.squeeze(boxes),
116 | np.squeeze(classes).astype(np.int32),
117 | np.squeeze(scores),
118 | category_index,
119 | min_score_thresh=0.3,
120 | use_normalized_coordinates=True,
121 | line_thickness=8)
122 | fig=plt.figure(figsize=IMAGE_SIZE)
123 | plt.axis('off')
124 | plt.title('The image including ')
125 | plt.imshow(image_np)
126 | #fig.savefig('demo.png', bbox_inches='tight')
127 | fig.savefig('', bbox_inches='tight') #enter a path for save
--------------------------------------------------------------------------------
/Tensorflow/scripts/preprocessing/xml_to_csv.py:
--------------------------------------------------------------------------------
1 | import os
2 | import glob
3 | import pandas as pd
4 | import argparse
5 | import xml.etree.ElementTree as ET
6 |
7 |
8 | def xml_to_csv(path):
9 | print('Path: ', path)
10 | xml_list = []
11 | for xml_file in glob.glob(path + '/*.xml'):
12 | print(xml_file)
13 | tree = ET.parse(xml_file)
14 | root = tree.getroot()
15 | for member in root.findall('object'):
16 | if (len(member)>2):
17 | value = (root.find('filename').text,
18 | int(root.find('size')[0].text),
19 | int(root.find('size')[1].text),
20 | member[0].text,
21 | int(member[4][0].text),
22 | int(member[4][1].text),
23 | int(member[4][2].text),
24 | int(member[4][3].text)
25 | )
26 | else :
27 | value = (root.find('filename').text,
28 | int(root.find('size')[0].text),
29 | int(root.find('size')[1].text),
30 | member[0].text,
31 | int(member[1][0].text),
32 | int(member[1][1].text),
33 | int(member[1][2].text),
34 | int(member[1][3].text)
35 | )
36 | xml_list.append(value)
37 | column_name = ['filename', 'width', 'height',
38 | 'class', 'xmin', 'ymin', 'xmax', 'ymax']
39 | xml_df = pd.DataFrame(xml_list, columns=column_name)
40 | return xml_df
41 |
42 |
43 | def main():
44 | path = '.../RoadDamageDetection-DeepLearning/Tensorflow/workspace/training_demo/images/'
45 | path_annotation = '.../RoadDamageDetection-DeepLearning/Tensorflow/workspace/training_demo/annotations/'
46 | for i in ['train', 'test']:
47 | image_path = os.path.join(path, '{}'.format(i))
48 | xml_df = xml_to_csv(image_path)
49 | csvpath = path_annotation + '{}_labels.csv'.format(i)
50 | print(csvpath)
51 | xml_df.to_csv(csvpath, index=None)
52 | print('Successfully converted xml to csv.')
53 |
54 | if __name__ == '__main__':
55 | main()
--------------------------------------------------------------------------------
/Tensorflow/workspace/training_demo/annotations/label_map.pbtxt:
--------------------------------------------------------------------------------
1 | item {
2 | id: 1
3 | name: 'D00'
4 | }
5 |
6 | item {
7 | id: 2
8 | name: 'D01'
9 | }
10 |
11 | item {
12 | id: 3
13 | name: 'D10'
14 | }
15 |
16 | item {
17 | id: 4
18 | name: 'D11'
19 | }
20 |
21 | item {
22 | id: 5
23 | name: 'D20'
24 | }
25 |
26 | item {
27 | id: 6
28 | name: 'D40'
29 | }
30 |
31 | item {
32 | id: 7
33 | name: 'D43'
34 | }
35 |
36 | item {
37 | id: 8
38 | name: 'D44'
39 | }
40 |
--------------------------------------------------------------------------------
/Tensorflow/workspace/training_demo/export_inference_graph.py:
--------------------------------------------------------------------------------
1 | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | # ==============================================================================
15 |
16 | r"""Tool to export an object detection model for inference.
17 |
18 | Prepares an object detection tensorflow graph for inference using model
19 | configuration and a trained checkpoint. Outputs inference
20 | graph, associated checkpoint files, a frozen inference graph and a
21 | SavedModel (https://tensorflow.github.io/serving/serving_basic.html).
22 |
23 | The inference graph contains one of three input nodes depending on the user
24 | specified option.
25 | * `image_tensor`: Accepts a uint8 4-D tensor of shape [None, None, None, 3]
26 | * `encoded_image_string_tensor`: Accepts a 1-D string tensor of shape [None]
27 | containing encoded PNG or JPEG images. Image resolutions are expected to be
28 | the same if more than 1 image is provided.
29 | * `tf_example`: Accepts a 1-D string tensor of shape [None] containing
30 | serialized TFExample protos. Image resolutions are expected to be the same
31 | if more than 1 image is provided.
32 |
33 | and the following output nodes returned by the model.postprocess(..):
34 | * `num_detections`: Outputs float32 tensors of the form [batch]
35 | that specifies the number of valid boxes per image in the batch.
36 | * `detection_boxes`: Outputs float32 tensors of the form
37 | [batch, num_boxes, 4] containing detected boxes.
38 | * `detection_scores`: Outputs float32 tensors of the form
39 | [batch, num_boxes] containing class scores for the detections.
40 | * `detection_classes`: Outputs float32 tensors of the form
41 | [batch, num_boxes] containing classes for the detections.
42 | * `raw_detection_boxes`: Outputs float32 tensors of the form
43 | [batch, raw_num_boxes, 4] containing detection boxes without
44 | post-processing.
45 | * `raw_detection_scores`: Outputs float32 tensors of the form
46 | [batch, raw_num_boxes, num_classes_with_background] containing class score
47 | logits for raw detection boxes.
48 | * `detection_masks`: Outputs float32 tensors of the form
49 | [batch, num_boxes, mask_height, mask_width] containing predicted instance
50 | masks for each box if its present in the dictionary of postprocessed
51 | tensors returned by the model.
52 |
53 | Notes:
54 | * This tool uses `use_moving_averages` from eval_config to decide which
55 | weights to freeze.
56 |
57 | Example Usage:
58 | --------------
59 | python export_inference_graph \
60 | --input_type image_tensor \
61 | --pipeline_config_path path/to/ssd_inception_v2.config \
62 | --trained_checkpoint_prefix path/to/model.ckpt \
63 | --output_directory path/to/exported_model_directory
64 |
65 | The expected output would be in the directory
66 | path/to/exported_model_directory (which is created if it does not exist)
67 | with contents:
68 | - inference_graph.pbtxt
69 | - model.ckpt.data-00000-of-00001
70 | - model.ckpt.info
71 | - model.ckpt.meta
72 | - frozen_inference_graph.pb
73 | + saved_model (a directory)
74 |
75 | Config overrides (see the `config_override` flag) are text protobufs
76 | (also of type pipeline_pb2.TrainEvalPipelineConfig) which are used to override
77 | certain fields in the provided pipeline_config_path. These are useful for
78 | making small changes to the inference graph that differ from the training or
79 | eval config.
80 |
81 | Example Usage (in which we change the second stage post-processing score
82 | threshold to be 0.5):
83 |
84 | python export_inference_graph \
85 | --input_type image_tensor \
86 | --pipeline_config_path path/to/ssd_inception_v2.config \
87 | --trained_checkpoint_prefix path/to/model.ckpt \
88 | --output_directory path/to/exported_model_directory \
89 | --config_override " \
90 | model{ \
91 | faster_rcnn { \
92 | second_stage_post_processing { \
93 | batch_non_max_suppression { \
94 | score_threshold: 0.5 \
95 | } \
96 | } \
97 | } \
98 | }"
99 | """
100 | import tensorflow as tf
101 | from google.protobuf import text_format
102 | from object_detection import exporter
103 | from object_detection.protos import pipeline_pb2
104 |
105 | slim = tf.contrib.slim
106 | flags = tf.app.flags
107 |
108 | flags.DEFINE_string('input_type', 'image_tensor', 'Type of input node. Can be '
109 | 'one of [`image_tensor`, `encoded_image_string_tensor`, '
110 | '`tf_example`]')
111 | flags.DEFINE_string('input_shape', None,
112 | 'If input_type is `image_tensor`, this can explicitly set '
113 | 'the shape of this input tensor to a fixed size. The '
114 | 'dimensions are to be provided as a comma-separated list '
115 | 'of integers. A value of -1 can be used for unknown '
116 | 'dimensions. If not specified, for an `image_tensor, the '
117 | 'default shape will be partially specified as '
118 | '`[None, None, None, 3]`.')
119 | flags.DEFINE_string('pipeline_config_path', None,
120 | 'Path to a pipeline_pb2.TrainEvalPipelineConfig config '
121 | 'file.')
122 | flags.DEFINE_string('trained_checkpoint_prefix', None,
123 | 'Path to trained checkpoint, typically of the form '
124 | 'path/to/model.ckpt')
125 | flags.DEFINE_string('output_directory', None, 'Path to write outputs.')
126 | flags.DEFINE_string('config_override', '',
127 | 'pipeline_pb2.TrainEvalPipelineConfig '
128 | 'text proto to override pipeline_config_path.')
129 | flags.DEFINE_boolean('write_inference_graph', False,
130 | 'If true, writes inference graph to disk.')
131 | tf.app.flags.mark_flag_as_required('pipeline_config_path')
132 | tf.app.flags.mark_flag_as_required('trained_checkpoint_prefix')
133 | tf.app.flags.mark_flag_as_required('output_directory')
134 | FLAGS = flags.FLAGS
135 |
136 |
137 | def main(_):
138 | pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
139 | with tf.gfile.GFile(FLAGS.pipeline_config_path, 'r') as f:
140 | text_format.Merge(f.read(), pipeline_config)
141 | text_format.Merge(FLAGS.config_override, pipeline_config)
142 | if FLAGS.input_shape:
143 | input_shape = [
144 | int(dim) if dim != '-1' else None
145 | for dim in FLAGS.input_shape.split(',')
146 | ]
147 | else:
148 | input_shape = None
149 | exporter.export_inference_graph(
150 | FLAGS.input_type, pipeline_config, FLAGS.trained_checkpoint_prefix,
151 | FLAGS.output_directory, input_shape=input_shape,
152 | write_inference_graph=FLAGS.write_inference_graph)
153 |
154 |
155 | if __name__ == '__main__':
156 | tf.app.run()
157 |
--------------------------------------------------------------------------------
/Tensorflow/workspace/training_demo/train.py:
--------------------------------------------------------------------------------
1 | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | # ==============================================================================
15 |
16 | r"""Training executable for detection models.
17 |
18 | This executable is used to train DetectionModels. There are two ways of
19 | configuring the training job:
20 |
21 | 1) A single pipeline_pb2.TrainEvalPipelineConfig configuration file
22 | can be specified by --pipeline_config_path.
23 |
24 | Example usage:
25 | ./train \
26 | --logtostderr \
27 | --train_dir=path/to/train_dir \
28 | --pipeline_config_path=pipeline_config.pbtxt
29 |
30 | 2) Three configuration files can be provided: a model_pb2.DetectionModel
31 | configuration file to define what type of DetectionModel is being trained, an
32 | input_reader_pb2.InputReader file to specify what training data will be used and
33 | a train_pb2.TrainConfig file to configure training parameters.
34 |
35 | Example usage:
36 | ./train \
37 | --logtostderr \
38 | --train_dir=path/to/train_dir \
39 | --model_config_path=model_config.pbtxt \
40 | --train_config_path=train_config.pbtxt \
41 | --input_config_path=train_input_config.pbtxt
42 | """
43 |
44 | import functools
45 | import json
46 | import os
47 | import tensorflow as tf
48 |
49 | from object_detection.builders import dataset_builder
50 | from object_detection.builders import graph_rewriter_builder
51 | from object_detection.builders import model_builder
52 | from object_detection.legacy import trainer
53 | from object_detection.utils import config_util
54 |
55 | tf.logging.set_verbosity(tf.logging.INFO)
56 |
57 | flags = tf.app.flags
58 | flags.DEFINE_string('master', '', 'Name of the TensorFlow master to use.')
59 | flags.DEFINE_integer('task', 0, 'task id')
60 | flags.DEFINE_integer('num_clones', 1, 'Number of clones to deploy per worker.')
61 | flags.DEFINE_boolean('clone_on_cpu', False,
62 | 'Force clones to be deployed on CPU. Note that even if '
63 | 'set to False (allowing ops to run on gpu), some ops may '
64 | 'still be run on the CPU if they have no GPU kernel.')
65 | flags.DEFINE_integer('worker_replicas', 1, 'Number of worker+trainer '
66 | 'replicas.')
67 | flags.DEFINE_integer('ps_tasks', 0,
68 | 'Number of parameter server tasks. If None, does not use '
69 | 'a parameter server.')
70 | flags.DEFINE_string('train_dir', '',
71 | 'Directory to save the checkpoints and training summaries.')
72 |
73 | flags.DEFINE_string('pipeline_config_path', '',
74 | 'Path to a pipeline_pb2.TrainEvalPipelineConfig config '
75 | 'file. If provided, other configs are ignored')
76 |
77 | flags.DEFINE_string('train_config_path', '',
78 | 'Path to a train_pb2.TrainConfig config file.')
79 | flags.DEFINE_string('input_config_path', '',
80 | 'Path to an input_reader_pb2.InputReader config file.')
81 | flags.DEFINE_string('model_config_path', '',
82 | 'Path to a model_pb2.DetectionModel config file.')
83 |
84 | FLAGS = flags.FLAGS
85 |
86 |
87 | @tf.contrib.framework.deprecated(None, 'Use object_detection/model_main.py.')
88 | def main(_):
89 | assert FLAGS.train_dir, '`train_dir` is missing.'
90 | if FLAGS.task == 0: tf.gfile.MakeDirs(FLAGS.train_dir)
91 | if FLAGS.pipeline_config_path:
92 | configs = config_util.get_configs_from_pipeline_file(
93 | FLAGS.pipeline_config_path)
94 | if FLAGS.task == 0:
95 | tf.gfile.Copy(FLAGS.pipeline_config_path,
96 | os.path.join(FLAGS.train_dir, 'pipeline.config'),
97 | overwrite=True)
98 | else:
99 | configs = config_util.get_configs_from_multiple_files(
100 | model_config_path=FLAGS.model_config_path,
101 | train_config_path=FLAGS.train_config_path,
102 | train_input_config_path=FLAGS.input_config_path)
103 | if FLAGS.task == 0:
104 | for name, config in [('model.config', FLAGS.model_config_path),
105 | ('train.config', FLAGS.train_config_path),
106 | ('input.config', FLAGS.input_config_path)]:
107 | tf.gfile.Copy(config, os.path.join(FLAGS.train_dir, name),
108 | overwrite=True)
109 |
110 | model_config = configs['model']
111 | train_config = configs['train_config']
112 | input_config = configs['train_input_config']
113 |
114 | model_fn = functools.partial(
115 | model_builder.build,
116 | model_config=model_config,
117 | is_training=True)
118 |
119 | def get_next(config):
120 | return dataset_builder.make_initializable_iterator(
121 | dataset_builder.build(config)).get_next()
122 |
123 | create_input_dict_fn = functools.partial(get_next, input_config)
124 |
125 | env = json.loads(os.environ.get('TF_CONFIG', '{}'))
126 | cluster_data = env.get('cluster', None)
127 | cluster = tf.train.ClusterSpec(cluster_data) if cluster_data else None
128 | task_data = env.get('task', None) or {'type': 'master', 'index': 0}
129 | task_info = type('TaskSpec', (object,), task_data)
130 |
131 | # Parameters for a single worker.
132 | ps_tasks = 0
133 | worker_replicas = 1
134 | worker_job_name = 'lonely_worker'
135 | task = 0
136 | is_chief = True
137 | master = ''
138 |
139 | if cluster_data and 'worker' in cluster_data:
140 | # Number of total worker replicas include "worker"s and the "master".
141 | worker_replicas = len(cluster_data['worker']) + 1
142 | if cluster_data and 'ps' in cluster_data:
143 | ps_tasks = len(cluster_data['ps'])
144 |
145 | if worker_replicas > 1 and ps_tasks < 1:
146 | raise ValueError('At least 1 ps task is needed for distributed training.')
147 |
148 | if worker_replicas >= 1 and ps_tasks > 0:
149 | # Set up distributed training.
150 | server = tf.train.Server(tf.train.ClusterSpec(cluster), protocol='grpc',
151 | job_name=task_info.type,
152 | task_index=task_info.index)
153 | if task_info.type == 'ps':
154 | server.join()
155 | return
156 |
157 | worker_job_name = '%s/task:%d' % (task_info.type, task_info.index)
158 | task = task_info.index
159 | is_chief = (task_info.type == 'master')
160 | master = server.target
161 |
162 | graph_rewriter_fn = None
163 | if 'graph_rewriter_config' in configs:
164 | graph_rewriter_fn = graph_rewriter_builder.build(
165 | configs['graph_rewriter_config'], is_training=True)
166 |
167 | trainer.train(
168 | create_input_dict_fn,
169 | model_fn,
170 | train_config,
171 | master,
172 | task,
173 | FLAGS.num_clones,
174 | worker_replicas,
175 | FLAGS.clone_on_cpu,
176 | ps_tasks,
177 | worker_job_name,
178 | is_chief,
179 | FLAGS.train_dir,
180 | graph_hook_fn=graph_rewriter_fn)
181 |
182 |
183 | if __name__ == '__main__':
184 | tf.app.run()
185 |
--------------------------------------------------------------------------------
/Tensorflow/workspace/training_demo/training/pipeline.config:
--------------------------------------------------------------------------------
1 | # SSD with Inception v2 configuration for MSCOCO Dataset.
2 | # Users should configure the fine_tune_checkpoint field in the train config as
3 | # well as the label_map_path and input_path fields in the train_input_reader and
4 | # eval_input_reader. Search for "PATH_TO_BE_CONFIGURED" to find the fields that
5 | # should be configured.
6 |
7 | model {
8 | ssd {
9 | num_classes: 8 # Set this to the number of different label classes
10 | box_coder {
11 | faster_rcnn_box_coder {
12 | y_scale: 10.0
13 | x_scale: 10.0
14 | height_scale: 5.0
15 | width_scale: 5.0
16 | }
17 | }
18 | matcher {
19 | argmax_matcher {
20 | matched_threshold: 0.5
21 | unmatched_threshold: 0.5
22 | ignore_thresholds: false
23 | negatives_lower_than_unmatched: true
24 | force_match_for_each_row: true
25 | }
26 | }
27 | similarity_calculator {
28 | iou_similarity {
29 | }
30 | }
31 | anchor_generator {
32 | ssd_anchor_generator {
33 | num_layers: 6
34 | min_scale: 0.2
35 | max_scale: 0.95
36 | aspect_ratios: 1.0
37 | aspect_ratios: 2.0
38 | aspect_ratios: 0.5
39 | aspect_ratios: 3.0
40 | aspect_ratios: 0.3333
41 | reduce_boxes_in_lowest_layer: true
42 | }
43 | }
44 | image_resizer {
45 | fixed_shape_resizer {
46 | height: 300
47 | width: 300
48 | }
49 | }
50 | box_predictor {
51 | convolutional_box_predictor {
52 | min_depth: 0
53 | max_depth: 0
54 | num_layers_before_predictor: 0
55 | use_dropout: false
56 | dropout_keep_probability: 0.8
57 | kernel_size: 3
58 | box_code_size: 4
59 | apply_sigmoid_to_scores: false
60 | conv_hyperparams {
61 | activation: RELU_6,
62 | regularizer {
63 | l2_regularizer {
64 | weight: 0.00004
65 | }
66 | }
67 | initializer {
68 | truncated_normal_initializer {
69 | stddev: 0.03
70 | mean: 0.0
71 | }
72 | }
73 | }
74 | }
75 | }
76 | feature_extractor {
77 | type: 'ssd_inception_v2' # Set to the name of your chosen pre-trained model
78 | min_depth: 16
79 | depth_multiplier: 1.0
80 | conv_hyperparams {
81 | activation: RELU_6,
82 | regularizer {
83 | l2_regularizer {
84 | weight: 0.00004
85 | }
86 | }
87 | initializer {
88 | truncated_normal_initializer {
89 | stddev: 0.03
90 | mean: 0.0
91 | }
92 | }
93 | batch_norm {
94 | train: true,
95 | scale: true,
96 | center: true,
97 | decay: 0.9997,
98 | epsilon: 0.001,
99 | }
100 | }
101 | override_base_feature_extractor_hyperparams: true
102 | }
103 | loss {
104 | classification_loss {
105 | weighted_sigmoid {
106 | }
107 | }
108 | localization_loss {
109 | weighted_smooth_l1 {
110 | }
111 | }
112 | hard_example_miner {
113 | num_hard_examples: 3000
114 | iou_threshold: 0.99
115 | loss_type: CLASSIFICATION
116 | max_negatives_per_positive: 3
117 | min_negatives_per_image: 0
118 | }
119 | classification_weight: 1.0
120 | localization_weight: 1.0
121 | }
122 | normalize_loss_by_num_matches: true
123 | post_processing {
124 | batch_non_max_suppression {
125 | score_threshold: 1e-8
126 | iou_threshold: 0.6
127 | max_detections_per_class: 100
128 | max_total_detections: 100
129 | }
130 | score_converter: SIGMOID
131 | }
132 | }
133 | }
134 |
135 | train_config: {
136 | batch_size: 12 # Increase/Decrease this value depending on the available memory (Higher values require more memory and vice-versa)
137 | optimizer {
138 | rms_prop_optimizer: {
139 | learning_rate: {
140 | exponential_decay_learning_rate {
141 | initial_learning_rate: 0.004
142 | decay_steps: 800720
143 | decay_factor: 0.95
144 | }
145 | }
146 | momentum_optimizer_value: 0.9
147 | decay: 0.9
148 | epsilon: 1.0
149 | }
150 | }
151 | fine_tune_checkpoint: ".../RoadDamageDetection-DeepLearning/Tensorflow/workspace/training_demo/pre-trained-model/model.ckpt" # Path to extracted files of pre-trained model
152 | from_detection_checkpoint: true
153 | # Note: The below line limits the training process to 200K steps, which we
154 | # empirically found to be sufficient enough to train the pets dataset. This
155 | # effectively bypasses the learning rate schedule (the learning rate will
156 | # never decay). Remove the below line to train indefinitely.
157 | num_steps: 200000
158 | data_augmentation_options {
159 | random_horizontal_flip {
160 | }
161 | }
162 | data_augmentation_options {
163 | ssd_random_crop {
164 | }
165 | }
166 | }
167 |
168 | train_input_reader: {
169 | tf_record_input_reader {
170 | input_path: ".../RoadDamageDetection-DeepLearning/Tensorflow/workspace/training_demo/annotations/train.record" # Path to training TFRecord file
171 | }
172 | label_map_path: ".../RoadDamageDetection-DeepLearning/Tensorflow/workspace/training_demo/annotations/label_map.pbtxt" # Path to label map file
173 | }
174 |
175 | eval_config: {
176 | num_examples: 8000
177 | # Note: The below line limits the evaluation process to 10 evaluations.
178 | # Remove the below line to evaluate indefinitely.
179 | max_evals: 10
180 | }
181 |
182 | eval_input_reader: {
183 | tf_record_input_reader {
184 | input_path: ".../RoadDamageDetection-DeepLearning/Tensorflow/workspace/training_demo/annotations/test.record" # Path to testing TFRecord
185 | }
186 | label_map_path: ".../RoadDamageDetection-DeepLearning/Tensorflow/workspace/training_demo/annotations/label_map.pbtxt" # Path to label map file
187 | shuffle: false
188 | num_readers: 1
189 | }
--------------------------------------------------------------------------------
/komutlar.txt:
--------------------------------------------------------------------------------
1 | CSV dosyasını TFRecord Dosyas�na �evirme:
2 | train.record için:
3 | python generate_tfrecord.py
4 | --label0=D00
5 | --label1=D01
6 | --label2=D10
7 | --label3=D11
8 | --label4=D20
9 | --label5=D40
10 | --label6=D43
11 | --label7=D44
12 | --csv_input=C:\Users\sglvladi\Documents\TensorFlow\workspace\training_demo\annotations\train_labels.csv
13 | --output_path=C:\Users\sglvladi\Documents\TensorFlow\workspace\training_demo\annotations\train.record
14 | --img_path=C:\Users\sglvladi\Documents\TensorFlow\workspace\training_demo\images\train
15 |
16 | test.record için:
17 | python generate_tfrecord.py
18 | --label0=D00
19 | --label1=D01
20 | --label2=D10
21 | --label3=D11
22 | --label4=D20
23 | --label5=D40
24 | --label6=D43
25 | --label7=D44
26 | --csv_input=C:\Users\sglvladi\Documents\TensorFlow\workspace\training_demo\annotations\test_labels.csv
27 | --output_path=C:\Users\sglvladi\Documents\TensorFlow\workspace\training_demo\annotations\test.record --img_path=C:\Users\sglvladi\Documents\TensorFlow\workspace\training_demo\images\test
28 |
29 | Eğitimi başlatmak için:
30 | python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/pipeline.config
31 |
32 | Tensorboard başlatmak i�in:(Anaconda Prompt)
33 | tensorboard --logdir=training\
34 |
35 | Ckpt dosyasını pb(Frozen Graph) çevirmek için:
36 | python export_inference_graph.py --input_type=image_tensor --pipeline_config_path=training/pipeline.config --trained_checkpoint_prefix=training/model.ckpt-4000 --output_directory=trained-inference-graphs/output_inference_graph_v1.pb
37 |
38 | Eğitim başlatmak için2 :
39 | gcloud ml-engine jobs submit training `whoami`_object_detection_`date +%s` \
40 | --job-dir="D:/Ders Notları/Proje&Bitirme/Bitirme/Python/ProjeDeneme/Tensorflow/workspace/training_demo/pre-trained-model" \
41 | --packages dist/object_detection-0.1.tar.gz,slim/dist/slim-0.1.tar.gz,/tmp/pycocotools/pycocotools-2.0.tar.gz \
42 | --module-name object_detection.model_tpu_main \
43 | --runtime-version 1.8 \
44 | --scale-tier BASIC_TPU \
45 | --region us-central1 \
46 | -- \
47 | --model_dir="D:/Ders Notları/Proje&Bitirme/Bitirme/Python/ProjeDeneme/Tensorflow/workspace/training_demo/pre-trained-model" \
48 | --tpu_zone us-central1 \
49 | --pipeline_config_path=gs:"D:/Ders Notları/Proje&Bitirme/Bitirme/Python/ProjeDeneme/Tensorflow/workspace/training_demo/training/pipeline.config"
50 |
51 | gcloud ml-engine jobs submit training `whoami`_object_detection_`date +%s` --job-dir="D:/Ders Notları/Proje&Bitirme/Bitirme/Python/ProjeDeneme/Tensorflow/workspace/training_demo/pre-trained-model" --packages dist/object_detection-0.1.tar.gz,slim/dist/slim-0.1.tar.gz,/tmp/pycocotools/pycocotools-2.0.tar.gz --module-name object_detection.model_tpu_main --runtime-version 1.8 --scale-tier BASIC_TPU --region us-central1 -- --model_dir="D:/Ders Notları/Proje&Bitirme/Bitirme/Python/ProjeDeneme/Tensorflow/workspace/training_demo/pre-trained-model" --tpu_zone us-central1 --pipeline_config_path=gs:"D:/Ders Notları/Proje&Bitirme/Bitirme/Python/ProjeDeneme/Tensorflow/workspace/training_demo/training/pipeline.config"
--------------------------------------------------------------------------------
/ssd-inception-v2-config.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ertkrn/RoadDamageDetection-DeepLearning/1af085a85c2e2abe7dcf2ed9550e89e3aae88bc5/ssd-inception-v2-config.txt
--------------------------------------------------------------------------------
/trainedModels/crack_label_map.pbtxt:
--------------------------------------------------------------------------------
1 | item {
2 | id: 1
3 | name: 'Tkrlk'
4 | }
5 |
6 | item {
7 | id: 2
8 | name: 'EkYol'
9 | }
10 |
11 | item {
12 | id: 3
13 | name: 'YtyCtlk'
14 | }
15 |
16 | item {
17 | id: 4
18 | name: 'YtyBrlsm'
19 | }
20 |
21 | item {
22 | id: 5
23 | name: 'Timsah'
24 | }
25 |
26 | item {
27 | id: 6
28 | name: 'Ckr'
29 | }
30 |
31 | item {
32 | id: 7
33 | name: 'YayaGecidi'
34 | }
35 |
36 | item {
37 | id: 8
38 | name: 'YolCizgisi'
39 | }
40 |
--------------------------------------------------------------------------------
/trainedModels/frozen_inference_graph.pb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ertkrn/RoadDamageDetection-DeepLearning/1af085a85c2e2abe7dcf2ed9550e89e3aae88bc5/trainedModels/frozen_inference_graph.pb
--------------------------------------------------------------------------------