darknet训练图像分类图像预处理研究

训练图像分类加载图片流程

load_data_augment()实现框架:

load_data_augment()函数做了三件事情:获取图片路径;加载图片;获取图片标签。

加载图片load_image_augment_paths又包括:load_image_color(),random_augment_image(),flip_image(),random_distort_image(). 

data load_data_augment(char **paths, int n, int m, char **labels, int k, tree *hierarchy, int use_flip, int min, int max, int size, float angle, float aspect, float hue, float saturation, float exposure)
{
    if(m) paths = get_random_paths(paths, n, m);
    data d = {0};
    d.shallow = 0;
    d.X = load_image_augment_paths(paths, n, use_flip, min, max, size, angle, aspect, hue, saturation, exposure);
    d.y = load_labels_paths(paths, n, labels, k, hierarchy);
    if(m) free(paths);
	
    return d;
}

 load_data_augment()参数说明:

data.c中load_thread()调用load_data_augment的代码:

void *load_thread(void *ptr)
{
    
    load_args a = *(struct load_args*)ptr;
    load_data_augment(a.paths, a.n, a.m, a.labels, a.classes, a.hierarchy, a.flip, a.min, a.max, a.size, a.angle, a.aspect, a.hue, a.saturation, a.exposure);
。。。。。
}

 

 

load_image_color()

load_image_color()中的图像处理函数是resize_image():关于resize_image(),参见darknet预测分类性能提升2.2:GPU加速resize_image()

resize_image()函数的本质,就是按照宽和高的比例进行缩放。

random_augment_image()

random_augment_image()调用说明:

 image crop = random_augment_image(im, angle, aspect, min, max, size);

random_augment_image()实现

flip_image()

翻转图片

调用:

flip_image(crop);

实现:

void flip_image(image a)
{
    int i,j,k;
    for(k = 0; k < a.c; ++k){
        for(i = 0; i < a.h; ++i){
            for(j = 0; j < a.w/2; ++j){
                int index = j + a.w*(i + a.h*(k));
                int flip = (a.w - j - 1) + a.w*(i + a.h*(k));
                float swap = a.data[flip];
                a.data[flip] = a.data[index];
                a.data[index] = swap;
            }
        }
    }
}

random_distort_image()

调用:

 random_distort_image(crop, hue, saturation, exposure);

实现:

darknet训练图像分类图像预处理random_distort_image研究

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

haimianjie2012

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值