本文主要是介绍数据集005:螺丝螺母目标检测数据集(含数据集下载链接),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
数据集简介
背景干净的目标检测数据集。
里面仅仅包含螺丝和螺母两种类别的目标,背景为干净的培养皿。图片数量约420张,train.txt 文件描述每个图片中的目标,label_list 文件描述类别
另附一个验证集合,有10张图片,eval.txt 描述图片中目标,格式和 train.txt 相同
部分代码
"""
训练常基于dark-net的YOLOv3网络,目标检测
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
os.environ["FLAGS_fraction_of_gpu_memory_to_use"] = '0.82'
import uuid
import numpy as np
import time
import six
import math
import random
import paddle
import paddle.fluid as fluid
import logging
import xml.etree.ElementTree
import codecs
import jsonfrom paddle.fluid.initializer import MSRA
from paddle.fluid.param_attr import ParamAttr
from paddle.fluid.regularizer import L2Decay
from PIL import Image, ImageEnhance, ImageDrawlogger = None
train_parameters = {"data_dir": "data/data6045","train_list": "train.txt","eval_list": "eval.txt","class_dim": -1,"label_dict": {},"num_dict": {},"image_count": -1,"continue_train": True, # 是否加载前一次的训练参数,接着训练"pretrained": False,"pretrained_model_dir": "./pretrained-model","save_model_dir": "./yolo-model","model_prefix": "yolo-v3","freeze_dir": "freeze_model","use_tiny": True, # 是否使用 裁剪 tiny 模型"max_box_num": 20, # 一幅图上最多有多少个目标"num_epochs": 1,"train_batch_size": 8, # 对于完整 yolov3,每一批的训练样本不能太多,内存会炸掉;如果使用 tiny,可以适当大一些"use_gpu": True,"yolo_cfg": {"input_size": [3, 448, 448], # 原版的边长大小为608,为了提高训练速度和预测速度,此处压缩为448"anchors": [7, 10, 12, 22, 24, 17, 22, 45, 46, 33, 43, 88, 85, 66, 115, 146, 275, 240],"anchor_mask": [[6, 7, 8], [3, 4, 5], [0, 1, 2]]},"yolo_tiny_cfg": {"input_size": [3, 256, 256],"anchors": [6, 8, 13, 15, 22, 34, 48, 50, 81, 100, 205, 191],"anchor_mask": [[3, 4, 5], [0, 1, 2]]},"ignore_thresh": 0.7,"mean_rgb": [127.5, 127.5, 127.5],"mode": "train","multi_data_reader_count": 4,"apply_distort": True,"nms_top_k": 300,"nms_pos_k": 300,"valid_thresh": 0.01,"nms_thresh": 0.45,"image_distort_strategy": {"expand_prob": 0.5,"expand_max_ratio": 4,"hue_prob": 0.5,"hue_delta": 18,"contrast_prob": 0.5,"contrast_delta": 0.5,"saturation_prob": 0.5,"saturation_delta": 0.5,"brightness_prob": 0.5,"brightness_delta": 0.125},"sgd_strategy": {"learning_rate": 0.002,"lr_epochs": [30, 50, 65],"lr_decay": [1, 0.5, 0.25, 0.1]},"early_stop": {"sample_frequency": 50,"successive_limit": 3,"min_loss": 2.5,"min_curr_map": 0.84}
}def init_train_parameters():"""初始化训练参数,主要是初始化图片数量,类别数:return:"""file_list = os.path.join(train_parameters['data_dir'], train_parameters['train_list'])label_list = os.path.join(train_parameters['data_dir'], "label_list")index = 0with codecs.open(label_list, encoding='utf-8') as flist:lines = [line.strip() for line in flist]for line in lines:train_parameters['num_dict'][index] = line.strip()train_parameters['label_dict'][line.strip()] = indexindex += 1train_parameters['class_dim'] = indexwith codecs.open(file_list, encoding='utf-8') as flist:lines = [line.strip() for line in flist]train_parameters['image_count'] = len(lines)
数据集链接:螺丝螺母目标检测数据集(430张)
这篇关于数据集005:螺丝螺母目标检测数据集(含数据集下载链接)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!