Mendeteksi objek khusus

Anda dapat mengunduh kode di halaman GitHub ( tautan )





Selamat datang di artikel tentang pengakuan. Karena saya menghabiskan sebagian besar waktu kerja saya di ruang kantor ruang terbuka, di mana setiap tempat diberi nomor, saya memutuskan untuk memberi tahu Anda tentang penglihatan komputer menggunakan contoh pelat biasa dengan nomor tempat kerja. Di sini kita akan melatih kembali jaringan saraf untuk mendeteksi pelat pilihan kita.





Saya menggunakan python3.7 dan nama semua modul berversi disimpan di file requirement.txt.





.





:





  • 500 , โ€” 100, 1000 , , 2.





  • / . 80%, - 20%.





  • TF .





  • . config ( , ).





  • .





  • .





  • .





TensorFlow , , 1000 . , , . , , - .





, ().





. , . LabelImg- , GitHub , .





LabelImg GitHub ()





LabelImg ()





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'
      
      



Terakhir, sebelum menjalankan skrip Python, Anda perlu mengubah variabel NUM_CLASSES di skrip agar sama dengan jumlah kelas yang ingin kami deteksi. Saya hanya menggunakan 1 kelas, jadi saya mengubahnya menjadi 1:

NUM_CLASSES = 1





Sejalan 65, Anda perlu mengatur gambar di mana pendeteksian akan dilakukan.





Setelah memulai, Anda akan melihat jendela dan pelat yang dikenali.





Sekian terima kasih atas perhatiannya.








All Articles