【数字图像处理】基于公开数据集的图像目标检测与分割
项目时间:2020冬
更新时间:2021.1.24
一、概述
图像目标检测与分割在智能视频分析、自动驾驶等领域有着广泛的应用,本项目基于微软公开数据集,综合利用彩色图像处理、特征提取、机器学习、深度学习、软件编程等知识,在静止图像中进行多目标、多类别的目标区域检测和像素级目标语义分割。
二、项目要求
1、功能要求
(1)下载图像数据集;
(2)视频预处理:利用编程语言(Python或Matlab)调用API及相关图像处理库(如OpenCV)对图像进行各种操作,包括尺寸归一化、装载、解析、标注可视化等任务,具备便捷的程序界面;
(3)目标检测:查找开源的已训练深度学习检测模型,或自己用训练集训练检测模型(加分项),通过编程对测试集图像进行目标检测,给出多图像(>=10幅,从测试集中随机取出)的检测精度;
(4)像素级目标分割:查找开源的已训练深度学习分割模型,或自己用训练集训练分割模型(加分项),通过编程对测试集图像进行目标语义分割,给出多图像(>=10幅,从测试集中随机取出)的分割精度。
2、实施要求
整个项目的程序可以采Python或Matlab编程实现各种功能,也可以采用其他语言,但要能在最后验收时实际运行演示,并提供测试接口(能够在验收时检测和分割给定的图像,给出结果精度)。
三、实施过程
基于yolov5s的人脸检测
环境搭建:此链接
模型训练:此链接
基于deeplabv3的图像语义分割
基于python-tkinter的GUI界面
main.py的一部分
if __name__ == '__main__':
# t2 = threading.Thread(target=GetFrame)
# t2.start()
global button_capture,button_detect_face,button_choose_picture,frame_pic,data_pic_1,data_pic_2,label_par_P,label_par_R,frame_result,label_iou,lb
root = tk.Tk()
root.title("数字图像课程项目")
root.geometry("1440x1080")
label_title = tk.Label(root,text = "数字图像处理课程项目",font ='Heiti 24 bold')
label_title.place(x = 500,y = 20)
label_par_P=tk.Label(root,text="P:",font ='Heiti 18 bold')
label_par_R=tk.Label(root,font ='Heiti 18 bold')
label_par_testpicnum = tk.Label(root, text="随机抽取测试集150张", font='Heiti 18 bold')
label_par_facenumdata = tk.Label(root, text="face_num(dataset):",font='Heiti 18 bold')
label_par_facenumdetected = tk.Label(root, text="face_num(detected):", font='Heiti 18 bold')
label_iou = tk.Label(root,font='Heiti 18 bold',anchor= 'w')
xVariable = tkinter.StringVar()
cb_func = ttk.Combobox(root,textvariable=xVariable)
cb_func.place(x=100,y=50)
cb_func["value"] = ("请选择功能", "yolov5人脸检测", "deeplabv3城市环境语义分割")
cb_func.current(0)
cb_func.bind("<<ComboboxSelected>>", ChooseFunction)
button_capture = tk.Button(root, text="打开摄像头(原图)", command=TestCap)
button_detect_face= tk.Button(root,text = "yolov5人脸检测",command=lambda :face_detected(0))
button_close_detected = tk.Button(root,text = "关闭摄像头",command=CloseCamera)
button_choose_picture=tk.Button(root,text = "选择图片",command = ChoosePicture)
button_show_dataset_face = tk.Button(root,text = "数据集信息",command=ShowDatasetInfo)
button_modeltest = tk.Button(root,text = "模型测试",command = ModelTest)
frame_pic = tk.Label(root)
frame_pic.place(x=50, y=150)
frame_pic_gray = tk.Label(root)
frame_pic_gray.place(x=750, y=150)
frame_pic_binary = tk.Label(root)
frame_pic_binary.place(x=750, y=400)
frame_result = tk.Label(root)
data_pic_1 = tk.Label(root)
data_pic_2 = tk.Label(root)
csframe=tk.Frame(root)
csframe.place(x=30,y=600)
sb = tk.Scrollbar(csframe)
sb.pack(side='right',fill=Y)
lb = tk.Listbox(csframe, width=100,yscrollcommand=sb.set)
lb.pack(side="left",fill=X)
# button_detect_face.place(x=200,y=100)
# button_capture.place(x=50,y=100)
# button_choose_picture.place(x=350,y=100)
root.mainloop()
源码:点击下载
打开yolov5/main.py:
修改第600行为wider_face数据集下图片的地址;
修改第601行为wider_face数据集标签的地址;
修改第609行为yolov5生成识别结果的地址;
修改第748行为cityscapes数据集下图片的地址;
修改第759行为cityscapes数据集标签的地址;