mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
?
This commit is contained in:
parent
ff7e03325a
commit
c521f87c9e
2
Makefile
2
Makefile
@ -25,7 +25,7 @@ CFLAGS+=-DGPU
|
||||
LDFLAGS+= -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand
|
||||
endif
|
||||
|
||||
OBJ=gemm.o utils.o cuda.o deconvolutional_layer.o convolutional_layer.o list.o image.o activations.o im2col.o col2im.o blas.o crop_layer.o dropout_layer.o maxpool_layer.o softmax_layer.o data.o matrix.o network.o connected_layer.o cost_layer.o parser.o option_list.o darknet.o detection_layer.o imagenet.o captcha.o detection.o route_layer.o
|
||||
OBJ=gemm.o utils.o cuda.o deconvolutional_layer.o convolutional_layer.o list.o image.o activations.o im2col.o col2im.o blas.o crop_layer.o dropout_layer.o maxpool_layer.o softmax_layer.o data.o matrix.o network.o connected_layer.o cost_layer.o parser.o option_list.o darknet.o detection_layer.o imagenet.o captcha.o detection.o route_layer.o writing.o
|
||||
ifeq ($(GPU), 1)
|
||||
OBJ+=convolutional_kernels.o deconvolutional_kernels.o activation_kernels.o im2col_kernels.o col2im_kernels.o blas_kernels.o crop_layer_kernels.o dropout_layer_kernels.o maxpool_layer_kernels.o softmax_layer_kernels.o network_kernels.o
|
||||
endif
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
extern void run_imagenet(int argc, char **argv);
|
||||
extern void run_detection(int argc, char **argv);
|
||||
extern void run_writing(int argc, char **argv);
|
||||
extern void run_captcha(int argc, char **argv);
|
||||
|
||||
void del_arg(int argc, char **argv, int index)
|
||||
@ -105,6 +106,8 @@ int main(int argc, char **argv)
|
||||
run_imagenet(argc, argv);
|
||||
} else if (0 == strcmp(argv[1], "detection")){
|
||||
run_detection(argc, argv);
|
||||
} else if (0 == strcmp(argv[1], "writing")){
|
||||
run_writing(argc, argv);
|
||||
} else if (0 == strcmp(argv[1], "test")){
|
||||
test_resize(argv[2]);
|
||||
} else if (0 == strcmp(argv[1], "captcha")){
|
||||
|
42
src/data.c
42
src/data.c
@ -49,6 +49,33 @@ char **get_random_paths(char **paths, int n, int m)
|
||||
return random_paths;
|
||||
}
|
||||
|
||||
char **find_replace_paths(char **paths, int n, char *find, char *replace)
|
||||
{
|
||||
char **replace_paths = calloc(n, sizeof(char*));
|
||||
int i;
|
||||
for(i = 0; i < n; ++i){
|
||||
char *replaced = find_replace(paths[i], find, replace);
|
||||
replace_paths[i] = copy_string(replaced);
|
||||
}
|
||||
return replace_paths;
|
||||
}
|
||||
|
||||
matrix load_image_paths_gray(char **paths, int n, int w, int h)
|
||||
{
|
||||
int i;
|
||||
matrix X;
|
||||
X.rows = n;
|
||||
X.vals = calloc(X.rows, sizeof(float*));
|
||||
X.cols = 0;
|
||||
|
||||
for(i = 0; i < n; ++i){
|
||||
image im = load_image(paths[i], w, h);
|
||||
X.vals[i] = im.data;
|
||||
X.cols = im.h*im.w*im.c;
|
||||
}
|
||||
return X;
|
||||
}
|
||||
|
||||
matrix load_image_paths(char **paths, int n, int w, int h)
|
||||
{
|
||||
int i;
|
||||
@ -497,6 +524,21 @@ pthread_t load_data_detection_thread(int n, char **paths, int m, int classes, in
|
||||
return thread;
|
||||
}
|
||||
|
||||
data load_data_writing(char **paths, int n, int m, int w, int h)
|
||||
{
|
||||
if(m) paths = get_random_paths(paths, n, m);
|
||||
char **replace_paths = find_replace_paths(paths, n, ".png", "label.png");
|
||||
data d;
|
||||
d.shallow = 0;
|
||||
d.X = load_image_paths(paths, n, w, h);
|
||||
d.y = load_image_paths_gray(replace_paths, n, w/4, h/4);
|
||||
if(m) free(paths);
|
||||
int i;
|
||||
for(i = 0; i < n; ++i) free(replace_paths[i]);
|
||||
free(replace_paths);
|
||||
return d;
|
||||
}
|
||||
|
||||
data load_data(char **paths, int n, int m, char **labels, int k, int w, int h)
|
||||
{
|
||||
if(m) paths = get_random_paths(paths, n, m);
|
||||
|
@ -41,6 +41,8 @@ pthread_t load_data_localization_thread(int n, char **paths, int m, int classes,
|
||||
data load_cifar10_data(char *filename);
|
||||
data load_all_cifar10();
|
||||
|
||||
data load_data_writing(char **paths, int n, int m, int w, int h);
|
||||
|
||||
list *get_paths(char *filename);
|
||||
char **get_labels(char *filename);
|
||||
void get_random_batch(data d, int n, float *X, float *y);
|
||||
|
@ -368,18 +368,11 @@ void forward_detection_layer(const detection_layer l, network_state state)
|
||||
|
||||
|
||||
*(l.cost) += pow((1-iou), 2);
|
||||
if(0){
|
||||
l.delta[j+0] = (state.truth[j+0] - l.output[j+0]);
|
||||
l.delta[j+1] = (state.truth[j+1] - l.output[j+1]);
|
||||
l.delta[j+2] = (state.truth[j+2] - l.output[j+2]);
|
||||
l.delta[j+3] = (state.truth[j+3] - l.output[j+3]);
|
||||
}else{
|
||||
l.delta[j+0] = 4 * (state.truth[j+0] - l.output[j+0]) / 7;
|
||||
l.delta[j+1] = 4 * (state.truth[j+1] - l.output[j+1]) / 7;
|
||||
l.delta[j+2] = 4 * (state.truth[j+2] - l.output[j+2]);
|
||||
l.delta[j+3] = 4 * (state.truth[j+3] - l.output[j+3]);
|
||||
}
|
||||
if(0){
|
||||
l.delta[j+0] = 4 * (state.truth[j+0] - l.output[j+0]);
|
||||
l.delta[j+1] = 4 * (state.truth[j+1] - l.output[j+1]);
|
||||
l.delta[j+2] = 4 * (state.truth[j+2] - l.output[j+2]);
|
||||
l.delta[j+3] = 4 * (state.truth[j+3] - l.output[j+3]);
|
||||
if(1){
|
||||
for (j = offset; j < offset+classes; ++j) {
|
||||
if(state.truth[j]) state.truth[j] = iou;
|
||||
l.delta[j] = state.truth[j] - l.output[j];
|
||||
|
@ -47,7 +47,7 @@ void train_imagenet(char *cfgfile, char *weightfile)
|
||||
avg_loss = avg_loss*.9 + loss*.1;
|
||||
printf("%d: %f, %f avg, %lf seconds, %d images\n", i, loss, avg_loss, sec(clock()-time), net.seen);
|
||||
free_data(train);
|
||||
if((i % 20000) == 0) net.learning_rate *= .1;
|
||||
if((i % 15000) == 0) net.learning_rate *= .1;
|
||||
//if(i%100 == 0 && net.learning_rate > .00001) net.learning_rate *= .97;
|
||||
if(i%1000==0){
|
||||
char buff[256];
|
||||
|
Loading…
x
Reference in New Issue
Block a user