当前位置:网站首页>Data reading in yolov3 (1)
Data reading in yolov3 (1)
2022-08-04 06:07:00 【Big Yellow Cat No. 1】
yolov3The training of the code from detector.c de train_detector()函数开始,函数如下:
void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, int ngpus, int clear, int dont_show)
If training code for:
*datacfg代表的是 voc.data ,*cfgfile代表的是 yolov3-voc.cfg
voc.data格式:
下面解读train_detector()下的函数.
list *options = read_data_cfg(datacfg);
这个函数的作用是解析voc.data中的数据,And the data deposited in the end nodes as options的双向链表中,
Inside the key function is:
int read_option(char *s, list *options)
{
size_t i;
size_t len = strlen(s);
char *val = 0;
for(i = 0; i < len; ++i){
if(s[i] == '='){
s[i] = '\0';
val = s+i+1;
break;
}
}
if(i == len-1) return 0;
char *key = s;
option_insert(options, key, val);
return 1;
}
It can be seen that program willvoc.data中的数据以“=”There are two types of for boundary character,左边为key 右边为val,然后插入到options链表中.在opton_insert()函数中可以看到,作者将key与val包装成一个node节点中的val,val的格式如下:
typedef struct{
char *key;
char *val;
int used;
} kvp;
以上,It can be seen that the author willvoc.dataAccording to each behavior of data in anodeNodes to join aoptions链表中,每个nodeContains three important information,分别为key,val,used(初始为零,标签处理),Three information into astruct.
下面函数:
char *train_images = option_find_str(options, "train", "data/train.list");
Training images address into the totrain_images中.同时将optionsHead pointer tokey为train的下一行,used设为1.至此,Put the pictures of the training address intotrain_images中.注意:这里train_imagesPointing to aWrite address of imagestxt文件的地址.
A network model of analytic:
char *base = basecfg(cfgfile);
The above function training code(4)cfg/After the data into the*base中.For example as:*base = yolov3-voc.cfg.
转入到parser.c文件中,解读network parse_network_cfg_custom(char *filename, int batch)
*filename是yolov3-voc.cfg,里面的batch是0;
这里看list *read_cfg()函数:
list *read_cfg(char *filename)
{
FILE *file = fopen(filename, "r");
if(file == 0) file_error(filename);
char *line;
int nu = 0;
list *sections = make_list(); //list链表 The neural network layer
section *current = 0; //section A neural network layer,类似于卷积层...
while((line=fgetl(file)) != 0){
++ nu;
strip(line);
switch(line[0]){
case '[':
current = malloc(sizeof(section));
list_insert(sections, current);
current->options = make_list();
current->type = line;
break;
case '\0':
case '#':
case ';':
free(line);
break;
default:
if(!read_option(line, current->options)){
fprintf(stderr, "Config file error line %d, could parse: %s\n", nu, line);
free(line);
}
break;
}
}
fclose(file);
return sections;
}
Watching this program before you put a few price comparison important structures:
typedef struct list{
int size;
node *front;
node *back;
} list;
typedef struct{
char *type;
list *options;
}section;
typedef struct node{
void *val;
struct node *next;
struct node *prev;
} node;
typedef struct{
char *key;
char *val;
int used;
} kvp;
This a few structure constitute a list,Below is the program read.
这里将yolov3-voc.cfgThe network layer of the chain into a list,名称为sections,Every node in the linked list islist结构体.At the same time for each layer parameters analytical to asection结构体中,结构体名为current,Put out the following function here:
void list_insert(list *l, void *val)
{
node *new = malloc(sizeof(node));
new->val = val;
new->next = 0;
if(!l->back){
l->front = new;
new->prev = 0;
}else{
l->back->next = new;
new->prev = l->back;
}
l->back = new;
++l->size;
}
From the function can see,作者将current包装成一个node->val,让后将nodeAs a node is inserted into thelist链表中,这里node->val(current)结构体是section,包含两个变量,tpye与options.
section结构体中包含一个list链表,名为options,Deep to bala bala can see,这个optionsList the main store in order toA network layerDifferent parameters in the,拿第一个[net]层为例.
type中的值是’net’,optionsThe node node中存储着’height=416’这一类数据,node中有key与val ,key = height,val=416.
转入到list *read_cfg(char *filename)Function of the following program segment:
case '[':
current = malloc(sizeof(section));
list_insert(sections, current);
current->options = make_list();
current->type = line;
break;
In this section you can see,在识别出"["After this symbol,作者将current插入到sections链表中,转入到list_insert()这个函数中:
void list_insert(list *l, void *val)
{
node *new = malloc(sizeof(node));
new->val = val;
new->next = 0;
if(!l->back){
l->front = new;
new->prev = 0;
}else{
l->back->next = new;
new->prev = l->back;
}
l->back = new;
++l->size;
}
Here is a two-way chain table insert program,最后的 ++l->size;表明一个yolov3网络结构有size个网络层,And when the first network layer from1开始的.
将current(Is a representative of the network layer)Head address as node is inserted into thesections(代表的是整个yolov3网络)链表中后,The author in the firstcurrent->optionsThe first address as the head of the list to create a list:
current->options = make_list();
The list of information stored in the procedures section:
default:
if(!read_option(line, current->options)){ //read_optionStore the parameters of each network layer
fprintf(stderr, "Config file error line %d, could parse: %s\n", nu, line);
free(line);
}
break;
read_option()函数如下:
int read_option(char *s, list *options)
{
size_t i;
size_t len = strlen(s);
char *val = 0;
for(i = 0; i < len; ++i){
if(s[i] == '='){
s[i] = '\0';
val = s+i+1;
break;
}
}
if(i == len-1) return 0;
char *key = s;
option_insert(options, key, val);
return 1;
}
This function mainly will I said abovesection插入到options中.最后在list *read_cfg(char *filename)Many times in the loop,A network layer tocurrent插入到sections中,And the parameters of a networkcurrent->otpions的链表中.
最终:将各个node链成一个options(list结构)链表,Represents a network layer parameters,The network layer name(“net”)赋值给type,而options与type合成为一个current.然后将currentAs a node chain intosections(list)中,sections是整个yolov3网络结构.
至此,The entire network is loaded into the listsections中.
边栏推荐
猜你喜欢

彻底搞懂箱形图分析
![[Deep Learning 21 Days Learning Challenge] 2. Complex sample classification and recognition - convolutional neural network (CNN) clothing image classification](/img/5f/e5db59bdca19b275b2139020ebc6ea.png)
[Deep Learning 21 Days Learning Challenge] 2. Complex sample classification and recognition - convolutional neural network (CNN) clothing image classification

【深度学习21天学习挑战赛】0、搭建学习环境

【CV-Learning】卷积神经网络

(九)哈希表

Thoroughly understand box plot analysis

超详细MySQL总结

fill_between in Matplotlib; np.argsort() function

判断字符串是否有子字符串重复出现

TensorFlow2 study notes: 6. Overfitting and underfitting, and their mitigation solutions
随机推荐
【深度学习21天学习挑战赛】3、使用自制数据集——卷积神经网络(CNN)天气识别
剑指 Offer 2022/7/9
TensorFlow2 study notes: 4. The first neural network model, iris classification
两个APP进行AIDL通信
WARNING: sql version 9.2, server version 11.0.Some psql features might not work.
【CV-Learning】卷积神经网络预备知识
EPSON RC+ 7.0 使用记录一
0, deep learning 21 days learning challenge 】 【 set up learning environment
智能合约安全——溢出漏洞
SQL的性能分析、优化
(十三)二叉排序树
8.30难题留坑:计数器问题和素数等差数列问题
【CV-Learning】图像分类
(十六)图的基本操作---两种遍历
【深度学习21天学习挑战赛】2、复杂样本分类识别——卷积神经网络(CNN)服装图像分类
Kubernetes集群安装
flink-sql自定义函数
MySQL leftmost prefix principle [I understand hh]
(五)栈及其应用
TensorFlow2学习笔记:5、常用激活函数