darknet/src/data.h

103 lines
2.8 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"
2013-11-13 22:50:38 +04:00
2015-04-15 10:32:32 +03:00
extern unsigned int data_seed;
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;
2016-05-07 02:25:16 +03:00
int *indexes;
2013-12-07 01:26:09 +04:00
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 {
2016-08-06 01:27:07 +03:00
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
2015-08-25 04:27:42 +03:00
} data_type;
typedef struct load_args{
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;
2015-08-25 04:27:42 +03:00
data *d;
image *im;
image *resized;
data_type type;
} 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
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);
data load_data(char **paths, int n, int m, char **labels, int k, int w, int h);
2016-06-03 01:25:24 +03:00
data load_data_detection(int n, char **paths, int m, int w, int h, int boxes, int classes, float jitter);
2016-03-01 00:54:12 +03:00
data load_data_tag(char **paths, int n, int m, int k, int min, int max, int size);
data load_data_augment(char **paths, int n, int m, char **labels, int k, int min, int max, int size);
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-05-07 02:25:16 +03:00
data load_data_study(char **paths, int n, int m, char **labels, int k, int min, int max, int size);
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-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);
2013-11-13 22:50:38 +04:00
#endif