darknet/src/data.h

113 lines
3.4 KiB
C
Raw Normal View History

2013-11-13 22:50:38 +04:00
#ifndef DATA_H
#define DATA_H
2014-12-12 00:15:26 +03:00
#include <pthread.h>
2013-11-13 22:50:38 +04:00
2013-12-07 01:26:09 +04:00
#include "matrix.h"
#include "list.h"
2015-06-16 09:22:44 +03:00
#include "image.h"
2016-10-21 23:16:43 +03:00
#include "tree.h"
2013-11-13 22:50:38 +04:00
2015-04-01 20:25:50 +03:00
static inline float distance_from_edge(int x, int max)
{
int dx = (max/2) - x;
if (dx < 0) dx = -dx;
dx = (max/2) + 1 - dx;
dx *= 2;
float dist = (float)dx/max;
if (dist > 1) dist = 1;
return dist;
}
2013-11-13 22:50:38 +04:00
typedef struct{
2015-12-14 22:57:10 +03:00
int w, h;
2013-12-07 01:26:09 +04:00
matrix X;
matrix y;
int shallow;
2016-05-11 20:45:50 +03:00
int *num_boxes;
box **boxes;
2013-12-07 01:26:09 +04:00
} data;
2013-11-13 22:50:38 +04:00
2015-08-25 04:27:42 +03:00
typedef enum {
CLASSIFICATION_DATA, DETECTION_DATA, CAPTCHA_DATA, REGION_DATA, IMAGE_DATA, COMPARE_DATA, WRITING_DATA, SWAG_DATA, TAG_DATA, OLD_CLASSIFICATION_DATA, STUDY_DATA, DET_DATA, SUPER_DATA, LETTERBOX_DATA, REGRESSION_DATA
2015-08-25 04:27:42 +03:00
} data_type;
typedef struct load_args{
2016-09-20 21:34:49 +03:00
int threads;
2015-08-25 04:27:42 +03:00
char **paths;
char *path;
int n;
int m;
char **labels;
int h;
int w;
2015-09-24 00:13:43 +03:00
int out_w;
int out_h;
2015-08-25 04:27:42 +03:00
int nh;
int nw;
int num_boxes;
2016-03-01 00:54:12 +03:00
int min, max, size;
2015-08-25 04:27:42 +03:00
int classes;
int background;
2016-08-06 01:27:07 +03:00
int scale;
2015-10-09 22:50:43 +03:00
float jitter;
2016-08-11 21:54:24 +03:00
float angle;
2016-09-08 08:27:56 +03:00
float aspect;
2016-08-11 21:54:24 +03:00
float saturation;
float exposure;
2016-09-02 02:48:41 +03:00
float hue;
2015-08-25 04:27:42 +03:00
data *d;
image *im;
image *resized;
data_type type;
2016-10-21 23:16:43 +03:00
tree *hierarchy;
2015-08-25 04:27:42 +03:00
} load_args;
2013-11-13 22:50:38 +04:00
2015-09-01 21:21:01 +03:00
typedef struct{
int id;
float x,y,w,h;
float left, right, top, bottom;
} box_label;
2013-12-07 01:26:09 +04:00
void free_data(data d);
2014-12-13 23:01:21 +03:00
2016-09-20 21:34:49 +03:00
pthread_t load_data(load_args args);
2015-08-25 04:27:42 +03:00
pthread_t load_data_in_thread(load_args args);
2015-02-24 05:52:05 +03:00
void print_letters(float *pred, int n);
2015-04-10 01:18:54 +03:00
data load_data_captcha(char **paths, int n, int m, int k, int w, int h);
data load_data_captcha_encode(char **paths, int n, int m, int w, int h);
2016-09-20 21:34:49 +03:00
data load_data_old(char **paths, int n, int m, char **labels, int k, int w, int h);
2016-09-02 02:48:41 +03:00
data load_data_detection(int n, char **paths, int m, int w, int h, int boxes, int classes, float jitter, float hue, float saturation, float exposure);
2016-09-08 08:27:56 +03:00
data load_data_tag(char **paths, int n, int m, int k, int min, int max, int size, float angle, float aspect, float hue, float saturation, float exposure);
matrix load_image_augment_paths(char **paths, int n, int min, int max, int size, float angle, float aspect, float hue, float saturation, float exposure);
2016-08-06 01:27:07 +03:00
data load_data_super(char **paths, int n, int m, int w, int h, int scale);
2016-10-21 23:16:43 +03:00
data load_data_augment(char **paths, int n, int m, char **labels, int k, tree *hierarchy, int min, int max, int size, float angle, float aspect, float hue, float saturation, float exposure);
data load_data_regression(char **paths, int n, int m, int min, int max, int size, float angle, float aspect, float hue, float saturation, float exposure);
2016-03-14 09:18:42 +03:00
data load_go(char *filename);
2014-12-28 20:42:35 +03:00
2015-09-01 21:21:01 +03:00
box_label *read_boxes(char *filename, int *n);
2014-03-13 08:57:34 +04:00
data load_cifar10_data(char *filename);
2014-08-08 23:04:15 +04:00
data load_all_cifar10();
2015-04-10 01:18:54 +03:00
2015-09-24 00:13:43 +03:00
data load_data_writing(char **paths, int n, int m, int w, int h, int out_w, int out_h);
2015-05-25 21:53:10 +03:00
list *get_paths(char *filename);
2014-10-25 22:57:26 +04:00
char **get_labels(char *filename);
void get_random_batch(data d, int n, float *X, float *y);
2016-09-20 21:34:49 +03:00
data get_data_part(data d, int part, int total);
2016-03-14 09:18:42 +03:00
data get_random_data(data d, int num);
void get_next_batch(data d, int n, int offset, float *X, float *y);
2013-12-07 01:26:09 +04:00
data load_categorical_data_csv(char *filename, int target, int k);
void normalize_data_rows(data d);
2014-02-14 22:26:31 +04:00
void scale_data_rows(data d, float s);
2014-07-14 09:07:51 +04:00
void translate_data_rows(data d, float s);
2013-12-07 01:26:09 +04:00
void randomize_data(data d);
2013-12-07 21:38:50 +04:00
data *split_data(data d, int part, int total);
data concat_data(data d1, data d2);
2016-08-06 01:27:07 +03:00
data concat_datas(data *d, int n);
2016-05-07 02:25:16 +03:00
void fill_truth(char *path, char **labels, int k, float *truth);
data copy_data(data d);
2013-11-13 22:50:38 +04:00
#endif