火焰识别--重新标注后的Deeplabv3+训练
1、使用labelme重新标注,图片总共202张
labelme的使用说明:在Anaconda中新建一个环境
conda create --name=labelme python=3.5
激活环境:
activate labelme
需要安装的库:
pip install labelme
pip install pyqt5
pip install pillow
安装好就可以在activate lebelme后启用labelme:
labelme
以后每次用两步:在命令行窗口输入
activate labelme
labelme
打开labelme的界面:
2、将json文件制造成数据集
第一部分:
将使用labelme生成的json文件转换成标注后的图片
import os
path = "D:\\...\\...\\..." # 使用labelme生成的json文件的保存位置
json_file = os.listdir(path)
for file in json_file:
os.system("labelme_json_to_dataset %s" % os.path.join(path,file))
第二部分:
第一部分生成的文件有多个,只需要红框中那个图片作为标注后ground truth:
将每个文件夹(0000_json … 0200_json)中的label.png取出来并命名成上一级文件夹0000_json中前面的数字如0000.png、0001.png…。
代码如下:
import os
import PIL.Image as Image
filepath = "D:\\fir_images\\fire\\2nd\\json_file"
for file in os.listdir(filepath):
pic_path = os.path.join(filepath, file, 'label.png')
pic = Image.open(pic_path)