1.收集数据
2.数据标注
pip install labelimg
3.划分数据集 0.2的验证机0.8的训练集
import os
from shutil import copyfile
from sys import exit
import randomsource = r"D:\Data\imgs\screenc" + '\\'
target_train = r"D:\Data\imgs\datasets\mydata\images\train" + '\\'
target_valid = r"D:\Data\imgs\datasets\mydata\images\valid" + '\\'source_txt = r"D:\Data\imgs\lable" + '\\'
target_txt_train = r"D:\Data\imgs\datasets\mydata\lables\train" + '\\'
target_txt_valid = r"D:\Data\imgs\datasets\mydata\lables\valid" + '\\'def creat_dir(dirs):if not os.path.exists(dirs):os.makedirs(dirs)creat_dir(target_train)
creat_dir(target_valid)
creat_dir(target_txt_train)
creat_dir(target_txt_valid)# 显示在所设置路径下的所有图片, filename这里仅为文件的文件名,如1.jpg
for filename in os.listdir(source):if '.png' in filename:source_filename = source + filename # 加一个根目录编程图片的路径if(random.random()>0.2):target_train_filename = target_train + filename # 加一个根目录编程图片的路径copyfile(source_filename, target_train_filename)source_txt_filename=source_txt+filename.split(".")[0]+".txt"copyfile(source_txt_filename, target_txt_train+filename.split(".")[0]+".txt")else:copyfile(source_filename, target_valid+ filename)copyfile(source_txt+filename.split(".")[0]+".txt", target_txt_valid+filename.split(".")[0]+".txt")
准确率(精确率),召回率
假定100人就诊,12人真的生病,10人被医生判为生病,9人被进一步检查确认真的生病。
准确率:9/10=0.9
召回率 9/12=0.75
f1=92/(92+3+1)=0.81