mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
Added Darknet reference model
This commit is contained in:
parent
2afa376bb3
commit
741ada451c
154
cfg/darknet.cfg
Normal file
154
cfg/darknet.cfg
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
[net]
|
||||||
|
batch=128
|
||||||
|
subdivisions=1
|
||||||
|
height=256
|
||||||
|
width=256
|
||||||
|
channels=3
|
||||||
|
learning_rate=0.01
|
||||||
|
momentum=0.9
|
||||||
|
decay=0.0005
|
||||||
|
|
||||||
|
[crop]
|
||||||
|
crop_height=224
|
||||||
|
crop_width=224
|
||||||
|
flip=1
|
||||||
|
angle=0
|
||||||
|
saturation=1
|
||||||
|
exposure=1
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
filters=16
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
#[convolutional]
|
||||||
|
#filters=16
|
||||||
|
#size=3
|
||||||
|
#stride=1
|
||||||
|
#pad=1
|
||||||
|
#activation=leaky
|
||||||
|
|
||||||
|
[maxpool]
|
||||||
|
stride=2
|
||||||
|
size=2
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
filters=32
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
#[convolutional]
|
||||||
|
#filters=32
|
||||||
|
#size=3
|
||||||
|
#stride=1
|
||||||
|
#pad=1
|
||||||
|
#activation=leaky
|
||||||
|
|
||||||
|
[maxpool]
|
||||||
|
stride=2
|
||||||
|
size=2
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
filters=64
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
#[convolutional]
|
||||||
|
#filters=64
|
||||||
|
#size=3
|
||||||
|
#stride=1
|
||||||
|
#pad=1
|
||||||
|
#activation=leaky
|
||||||
|
|
||||||
|
[maxpool]
|
||||||
|
stride=2
|
||||||
|
size=2
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
filters=128
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
#[convolutional]
|
||||||
|
#filters=128
|
||||||
|
#size=3
|
||||||
|
#stride=1
|
||||||
|
#pad=1
|
||||||
|
#activation=leaky
|
||||||
|
|
||||||
|
[maxpool]
|
||||||
|
stride=2
|
||||||
|
size=2
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
filters=256
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
#[convolutional]
|
||||||
|
#filters=256
|
||||||
|
#size=3
|
||||||
|
#stride=1
|
||||||
|
#pad=1
|
||||||
|
#activation=leaky
|
||||||
|
|
||||||
|
[maxpool]
|
||||||
|
stride=2
|
||||||
|
size=2
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
filters=512
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
#[convolutional]
|
||||||
|
#filters=512
|
||||||
|
#size=3
|
||||||
|
#stride=1
|
||||||
|
#pad=1
|
||||||
|
#activation=leaky
|
||||||
|
|
||||||
|
[maxpool]
|
||||||
|
stride=2
|
||||||
|
size=2
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
filters=1024
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
#[convolutional]
|
||||||
|
#filters=1024
|
||||||
|
#size=3
|
||||||
|
#stride=1
|
||||||
|
#pad=1
|
||||||
|
#activation=leaky
|
||||||
|
|
||||||
|
[avgpool]
|
||||||
|
|
||||||
|
[dropout]
|
||||||
|
probability=.5
|
||||||
|
|
||||||
|
[connected]
|
||||||
|
output=1000
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[softmax]
|
||||||
|
|
||||||
|
[cost]
|
||||||
|
type=sse
|
||||||
|
|
@ -5,6 +5,7 @@
|
|||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "cuda.h"
|
#include "cuda.h"
|
||||||
|
#include "blas.h"
|
||||||
|
|
||||||
#ifdef OPENCV
|
#ifdef OPENCV
|
||||||
#include "opencv2/highgui/highgui_c.h"
|
#include "opencv2/highgui/highgui_c.h"
|
||||||
@ -33,8 +34,55 @@ void change_rate(char *filename, float scale, float add)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void average(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char *cfgfile = argv[2];
|
||||||
|
char *outfile = argv[3];
|
||||||
|
gpu_index = -1;
|
||||||
|
network net = parse_network_cfg(cfgfile);
|
||||||
|
network sum = parse_network_cfg(cfgfile);
|
||||||
|
|
||||||
|
char *weightfile = argv[4];
|
||||||
|
load_weights(&sum, weightfile);
|
||||||
|
|
||||||
|
int i, j;
|
||||||
|
int n = argc - 5;
|
||||||
|
for(i = 0; i < n; ++i){
|
||||||
|
weightfile = argv[i+5];
|
||||||
|
load_weights(&net, weightfile);
|
||||||
|
for(j = 0; j < net.n; ++j){
|
||||||
|
layer l = net.layers[j];
|
||||||
|
layer out = sum.layers[j];
|
||||||
|
if(l.type == CONVOLUTIONAL){
|
||||||
|
int num = l.n*l.c*l.size*l.size;
|
||||||
|
axpy_cpu(l.n, 1, l.biases, 1, out.biases, 1);
|
||||||
|
axpy_cpu(num, 1, l.filters, 1, out.filters, 1);
|
||||||
|
}
|
||||||
|
if(l.type == CONNECTED){
|
||||||
|
axpy_cpu(l.outputs, 1, l.biases, 1, out.biases, 1);
|
||||||
|
axpy_cpu(l.outputs*l.inputs, 1, l.weights, 1, out.weights, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
n = n+1;
|
||||||
|
for(j = 0; j < net.n; ++j){
|
||||||
|
layer l = sum.layers[j];
|
||||||
|
if(l.type == CONVOLUTIONAL){
|
||||||
|
int num = l.n*l.c*l.size*l.size;
|
||||||
|
scal_cpu(l.n, 1./n, l.biases, 1);
|
||||||
|
scal_cpu(num, 1./n, l.filters, 1);
|
||||||
|
}
|
||||||
|
if(l.type == CONNECTED){
|
||||||
|
scal_cpu(l.outputs, 1./n, l.biases, 1);
|
||||||
|
scal_cpu(l.outputs*l.inputs, 1./n, l.weights, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
save_weights(sum, outfile);
|
||||||
|
}
|
||||||
|
|
||||||
void partial(char *cfgfile, char *weightfile, char *outfile, int max)
|
void partial(char *cfgfile, char *weightfile, char *outfile, int max)
|
||||||
{
|
{
|
||||||
|
gpu_index = -1;
|
||||||
network net = parse_network_cfg(cfgfile);
|
network net = parse_network_cfg(cfgfile);
|
||||||
if(weightfile){
|
if(weightfile){
|
||||||
load_weights_upto(&net, weightfile, max);
|
load_weights_upto(&net, weightfile, max);
|
||||||
@ -87,9 +135,9 @@ void visualize(char *cfgfile, char *weightfile)
|
|||||||
load_weights(&net, weightfile);
|
load_weights(&net, weightfile);
|
||||||
}
|
}
|
||||||
visualize_network(net);
|
visualize_network(net);
|
||||||
#ifdef OPENCV
|
#ifdef OPENCV
|
||||||
cvWaitKey(0);
|
cvWaitKey(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
@ -114,6 +162,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if(0==strcmp(argv[1], "imagenet")){
|
if(0==strcmp(argv[1], "imagenet")){
|
||||||
run_imagenet(argc, argv);
|
run_imagenet(argc, argv);
|
||||||
|
} else if (0 == strcmp(argv[1], "average")){
|
||||||
|
average(argc, argv);
|
||||||
} else if (0 == strcmp(argv[1], "detection")){
|
} else if (0 == strcmp(argv[1], "detection")){
|
||||||
run_detection(argc, argv);
|
run_detection(argc, argv);
|
||||||
} else if (0 == strcmp(argv[1], "yolo")){
|
} else if (0 == strcmp(argv[1], "yolo")){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user