python怎么读取图像的txt标注_使用包含文件名的.txt文件读取图像数据
使用新的數據集API(作為TF 1.4版本的一部分發布)來加快整個過程
讀取CSV文件的步驟:
1)讀取CSV文件名
2) 通過提供CSV文件名創建TextLineDataset
3) 為解碼創建Parse函數,并對輸入數據執行任何預處理工作
4) 使用前面步驟中創建的數據集創建批處理、重復(epoch編號)和無序處理
5) 創建迭代器,將所需的輸入作為批處理(即小批量)
Eg代碼:from matplotlib.image import imread
def input_model_function():
csv_filename =['images.txt']
dataset = tf.data.TextLineDataset(csv_filename)
dataset = dataset.map(_parse_function)
dataset = dataset.batch(20)# you can use any number of batching
iterator = dataset.make_one_shot_iterator()
sess = tf.Session()
batch_images, batch_labels = sess.run(iterator.get_next())
return {'x':batch_images}, batch_labels
def _parse_function(line):
image, labels= tf.decode_csv(line,record_defaults=[[""], [0]])
# Decode the raw bytes so it becomes a tensor with type.
image = imread(image)# give full path name of image
return image, labels
最后將批處理數據集輸入模型(使用任何預先制作的估計器或自定義估計器API創建)
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的python怎么读取图像的txt标注_使用包含文件名的.txt文件读取图像数据的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CAN总线技术 | 数据链路层01 -
- 下一篇: 电脑同时安装python2和3_一台电脑