Sie können den Code auf der GitHub-Seite herunterladen ( Link )
Willkommen zum Artikel über Anerkennung. Da ich den größten Teil meiner Arbeitszeit in einem offenen Büroraum verbringe, in dem jeder Ort nummeriert ist, habe ich beschlossen, Ihnen am Beispiel eines normalen Schilds mit einer Arbeitsplatznummer etwas über Computer Vision zu erzählen. Hier werden wir das neuronale Netzwerk neu trainieren, um die Platte unserer Wahl zu erkennen.
Ich verwende python3.7 und die Namen aller versionierten Module werden in der Datei require.txt gespeichert.
.
:
500 , — 100, 1000 , , 2.
/ . 80%, - 20%.
TF .
. config ( , ).
.
.
.
TensorFlow , , 1000 . , , . , , - .
, ().
. , . LabelImg- , GitHub , .
LabelImg, GUI. — dir , . create rectbox. , . , ! w, , ctrl+s, . 1 100 , , . , !
LabelImg xml-, . xml- TFRecords, TensorFlow. , , \test \train xml-.
, . , 20% XML- test, train.
, , TFRecords, TensorFlow.
-, image .xml csv-, . , : python xml_to_csv.py.
train_labels.csv test_labels.csv CSGO_images. cmd, .bat xml_to_csv.bat.
generate_tfrecord.py . , . labelmap.pbtxt.
, , generate_tfrecord.py:
# TO-DO label map
def class_text_to_int(row_label):
if row_label == 'table':
return 1
else:
return None
TFRecord, generate_tfrecord.bat.
train.record test.record training. .
, — . , , . labelmap.pbtxt CSGO_training. . , generate_tfrecord.py.
item {
id: 1
name: 'table'
}
, . , . .
TensorFlow research\ object_detection\ samples\ configs faster_rcnn_ inception_v2_ coco.config CSGO_training. . .config , , . 10. num_classes , . :
num_classes : 1
107. fine_tune_checkpoint :
fine_tune_checkpoint : "faster_rcnn_inception_v2_coco_2018_01_28 / model.ckpt"
122 124. train_input_reader input_path label_map_path :
input_path: "CSGO_images / train. record"
label_map_path: "CSGO_training / labelmap.pbtxt"
128. num_examples , CSGO_images\test. 113 , :
num_examples: 113
( )
136 138. eval_input_reader input_path label_map_path :
input_path: "CSGO_images / test. record"
label_map_path: "CSGO_training / labelmap.pbtxt"
. ! . .
, train.bat.
. . 1.5 . , 0,05, ( , ). , . , , .
.
, , — ( ). graph export_inference_graph.py, , “XXXX” ” model.ckpt-XXXX » .ckpt :
python export_inference_graph.py --input_type image_tensor --pipeline_config_path CSGO_training/faster_rcnn_inception_v2_coco.config --trained_checkpoint_prefix CSGO_training/model.ckpt-XXXX --output_directory CSGO_inference_graph
frozen_inference_graph.pb /coco_v3/ CSGO_inference_ graph. .pb . frozen_inference_graph.pb . coco_v3 predict.py 39 .
PATH_TO_FROZEN_GRAPH = 'graph/frozen_inference_graph.pb'
41 labelmap.
PATH_TO_LABELS = 'graph/labelmap.pbtxt'
Bevor Sie Python-Skripte ausführen, müssen Sie die Variable NUM_CLASSES im Skript so ändern, dass sie der Anzahl der Klassen entspricht, die erkannt werden sollen. Ich benutze nur 1 Klasse, also habe ich sie in 1 geändert:
NUM_CLASSES = 1
In Zeile 65 müssen Sie das Bild einstellen, auf dem die Erkennung stattfinden soll.
Nach dem Start sehen Sie ein Fenster und eine erkannte Platte.
Das ist alles, danke für Ihre Aufmerksamkeit.