Object Detection API(2)——?自定義數(shù)據(jù)組織:
本節(jié)的目的在于記錄將自己的數(shù)據(jù)組織成Object Detection API可以訓(xùn)練的數(shù)據(jù),即record格式。
(1)標(biāo)注圖像:使用lablme開(kāi)源工具,自行百度下載,GitHub有各平臺(tái)安裝方法。
下面給出windows平臺(tái)與Anaconda環(huán)境下的安裝方式
You need install?Anaconda, then run below:
# python2
conda create --name=labelme python=2.7source?activate labelme# conda install -c conda-forge pyside2
conda install pyqt
pip install labelme# if you'd like to use the latest version. run below:# pip install git+https://github.com/wkentaro/labelme.git
# python3
conda create --name=labelme python=3.6source?activate labelme# conda install -c conda-forge pyside2# conda install pyqt
pip install pyqt5 ?# pyqt5 can be installed via pip on python3
pip install labelme
(2)使用開(kāi)源標(biāo)注工具Lablme來(lái)標(biāo)注圖像,生成了.xml格式的標(biāo)注數(shù)據(jù),數(shù)據(jù)包括了目標(biāo)名稱,坐上角坐標(biāo),右下角坐標(biāo)等。
(3)然后通過(guò)Object Detection API生成record數(shù)據(jù):
運(yùn)行data-precess.py程序,代碼參考[1],本文對(duì)其進(jìn)行了修改,加入了xml讀取函數(shù),可以直接讀取xml格式的標(biāo)注文件,生成record數(shù)據(jù)。輸入文件為”標(biāo)注.xml”與?“原圖像.jpg”輸出文件為:Out.record
程序運(yùn)行過(guò)程中遇到一些問(wèn)題:
??E1:
Traceback (most recent call last):
??File "G:/git/models-master/research/Data_preprocessing.py", line 143, in
????tf.app.run()
??File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 126, in run
????_sys.exit(main(argv))
??File "G:/git/models-master/research/Data_preprocessing.py", line 136, in main
????tf_example = create_tf_example(img_url,ans_url)
??File "G:/git/models-master/research/Data_preprocessing.py", line 119, in create_tf_example
????'image/object/class/text': dataset_util.bytes_list_feature(classes_text),
??File "G:\git\models-master\research\object_detection\utils\dataset_util.py", line 34, in bytes_list_feature
????return tf.train.Feature(bytes_list=tf.train.BytesList(value=value))
TypeError: 'face' has type str, but expected one of: bytes
解決如下:
E2:
Traceback (most recent call last):
??File "G:/git/models-master/research/Data_preprocessing.py", line 143, in
????tf.app.run()
??File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 126, in run
????_sys.exit(main(argv))
??File "G:/git/models-master/research/Data_preprocessing.py", line 125, in main
????writer = tf.python_io.TFRecordWriter(FLAGS.output_path)#'./out.record'
??File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\lib\io\tf_record.py", line 111, in __init__
????compat.as_bytes(path), compat.as_bytes(compression_type), status)
??File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 516, in __exit__
????c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.UnknownError:?Failed to create a NewWriteableFile: G:/git/models-master/research/date_demo/ : \udcbe?\udcf8\udcb7\udcc3\udcce?\udca3
; Input/output error
解決如下:
參考資料:
[1]https://github.com/luyishisi/tensorflow/tree/master/4.Object_Detection
版權(quán)聲明:本文為博主原創(chuàng)文章,轉(zhuǎn)載請(qǐng)聯(lián)系作者取得授權(quán)。