This commit is contained in:
Joseph Redmon 2017-06-01 20:31:13 -07:00
parent 1ef829e585
commit 56d69e73ab
87 changed files with 915 additions and 888 deletions

View File

@ -1,6 +1,6 @@
GPU=1
CUDNN=1
OPENCV=1
GPU=0
CUDNN=0
OPENCV=0
DEBUG=0
ARCH= -gencode arch=compute_20,code=[sm_20,sm_21] \
@ -10,7 +10,7 @@ ARCH= -gencode arch=compute_20,code=[sm_20,sm_21] \
-gencode arch=compute_52,code=[sm_52,compute_52]
# This is what I use, uncomment if you know your arch and want to specify
ARCH= -gencode arch=compute_52,code=compute_52
# ARCH= -gencode arch=compute_52,code=compute_52
VPATH=./src/:./examples
LIB=libdarknet.a
@ -23,7 +23,7 @@ AR=ar
ARFLAGS=-rv
OPTS=-Ofast
LDFLAGS= -lm -pthread
COMMON= -Iinclude/
COMMON= -Iinclude/ -Isrc/
CFLAGS=-Wall -Wfatal-errors
ifeq ($(DEBUG), 1)
@ -60,7 +60,7 @@ endif
EXECOBJ = $(addprefix $(OBJDIR), $(EXECOBJA))
OBJS = $(addprefix $(OBJDIR), $(OBJ))
DEPS = $(wildcard include/darknet/*.h) Makefile
DEPS = $(wildcard src/*.h) Makefile include/darknet.h
all: obj backup results $(LIB) $(EXEC)

View File

@ -1,9 +1,5 @@
#include "darknet/network.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet/option_list.h"
#include "darknet/blas.h"
#include "darknet/classifier.h"
#include "darknet.h"
#include <sys/time.h>
void demo_art(char *cfgfile, char *weightfile, int cam_index)

View File

@ -1,6 +1,4 @@
#include "darknet/network.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet.h"
void fix_data_captcha(data d, int mask)
{

View File

@ -1,8 +1,4 @@
#include "darknet/network.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet/option_list.h"
#include "darknet/blas.h"
#include "darknet.h"
void train_cifar(char *cfgfile, char *weightfile)
{

View File

@ -1,10 +1,5 @@
#include "darknet/network.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet/option_list.h"
#include "darknet/blas.h"
#include "darknet/classifier.h"
#include "darknet/cuda.h"
#include "darknet.h"
#include <sys/time.h>
#include <assert.h>
@ -37,11 +32,7 @@ void train_classifier(char *datacfg, char *cfgfile, char *weightfile, int *gpus,
#ifdef GPU
cuda_set_device(gpus[i]);
#endif
nets[i] = parse_network_cfg(cfgfile);
if(weightfile){
load_weights(&nets[i], weightfile);
}
if(clear) *nets[i].seen = 0;
nets[i] = load_network(cfgfile, weightfile, clear);
nets[i].learning_rate *= ngpus;
}
srand(time(0));

View File

@ -1,12 +1,6 @@
#include <stdio.h>
#include "darknet.h"
#include "darknet/network.h"
#include "darknet/detection_layer.h"
#include "darknet/cost_layer.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet/box.h"
#include "darknet/demo.h"
#include <stdio.h>
char *coco_classes[] = {"person","bicycle","car","motorcycle","airplane","bus","train","truck","boat","traffic light","fire hydrant","stop sign","parking meter","bench","bird","cat","dog","horse","sheep","cow","elephant","bear","zebra","giraffe","backpack","umbrella","handbag","tie","suitcase","frisbee","skis","snowboard","sports ball","kite","baseball bat","baseball glove","skateboard","surfboard","tennis racket","bottle","wine glass","cup","fork","knife","spoon","bowl","banana","apple","sandwich","orange","broccoli","carrot","hot dog","pizza","donut","cake","chair","couch","potted plant","bed","dining table","toilet","tv","laptop","mouse","remote","keyboard","cell phone","microwave","oven","toaster","sink","refrigerator","book","clock","vase","scissors","teddy bear","hair drier","toothbrush"};

View File

@ -1,14 +1,9 @@
#include "darknet.h"
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include "darknet/parser.h"
#include "darknet/utils.h"
#include "darknet/cuda.h"
#include "darknet/blas.h"
#include "darknet/connected_layer.h"
#include "darknet/convolutional_layer.h"
extern void predict_classifier(char *datacfg, char *cfgfile, char *weightfile, char *filename, int top);
extern void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filename, float thresh, float hier_thresh, char *outfile, int fullscreen);
extern void run_voxel(int argc, char **argv);

View File

@ -1,12 +1,4 @@
#include "darknet/network.h"
#include "darknet/region_layer.h"
#include "darknet/cost_layer.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet/box.h"
#include "darknet/demo.h"
#include "darknet/option_list.h"
#include "darknet/blas.h"
#include "darknet.h"
static int coco_ids[] = {1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,27,28,31,32,33,34,35,36,37,38,39,40,41,42,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,67,70,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90};

View File

@ -1,6 +1,4 @@
#include "darknet/network.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet.h"
char *dice_labels[] = {"face1","face2","face3","face4","face5","face6"};

View File

@ -1,9 +1,5 @@
#include "darknet/network.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet/option_list.h"
#include "darknet/blas.h"
#include "darknet/data.h"
#include "darknet.h"
#include <unistd.h>
int inverted = 1;

View File

@ -1,8 +1,4 @@
#include "darknet/network.h"
#include "darknet/cost_layer.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet/blas.h"
#include "darknet.h"
/*
void train_lsd3(char *fcfg, char *fweight, char *gcfg, char *gweight, char *acfg, char *aweight, int clear)

View File

@ -1,8 +1,4 @@
#include "darknet/network.h"
#include "darknet/parser.h"
#include "darknet/blas.h"
#include "darknet/utils.h"
#include "darknet/region_layer.h"
#include "darknet.h"
// ./darknet nightmare cfg/extractor.recon.cfg ~/trained/yolo-coco.conv frame6.png -reconstruct -iters 500 -i 3 -lambda .1 -rate .01 -smooth 2

View File

@ -1,9 +1,4 @@
#include "darknet/network.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet/option_list.h"
#include "darknet/blas.h"
#include "darknet/cuda.h"
#include "darknet.h"
#include <sys/time.h>
#include <assert.h>

View File

@ -1,8 +1,4 @@
#include "darknet/network.h"
#include "darknet/cost_layer.h"
#include "darknet/utils.h"
#include "darknet/blas.h"
#include "darknet/parser.h"
#include "darknet.h"
typedef struct {
float *x;

View File

@ -1,8 +1,4 @@
#include "darknet/network.h"
#include "darknet/cost_layer.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet/blas.h"
#include "darknet.h"
#ifdef OPENCV
image get_image_from_stream(CvCapture *cap);

View File

@ -1,9 +1,4 @@
#include "darknet/network.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet/option_list.h"
#include "darknet/blas.h"
#include "darknet/cuda.h"
#include "darknet.h"
#include <sys/time.h>
#include <assert.h>
@ -153,7 +148,9 @@ void predict_segmenter(char *datafile, char *cfgfile, char *weightfile, char *fi
image rgb = mask_to_rgb(m);
show_image(sized, "orig");
show_image(rgb, "pred");
#ifdef OPENCV
cvWaitKey(0);
#endif
printf("Predicted: %f\n", predictions[0]);
printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time));
free_image(im);

View File

@ -1,7 +1,4 @@
#include "darknet/network.h"
#include "darknet/cost_layer.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet.h"
void train_super(char *cfgfile, char *weightfile, int clear)
{

View File

@ -1,9 +1,5 @@
#include "darknet/network.h"
#include "darknet/detection_layer.h"
#include "darknet/cost_layer.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet/box.h"
#include "darknet.h"
#include <sys/time.h>
void train_swag(char *cfgfile, char *weightfile)
{

View File

@ -1,6 +1,4 @@
#include "darknet/network.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet.h"
void train_tag(char *cfgfile, char *weightfile, int clear)
{

View File

@ -1,7 +1,4 @@
#include "darknet/network.h"
#include "darknet/cost_layer.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet.h"
void extract_voxel(char *lfile, char *rfile, char *prefix)
{

View File

@ -1,6 +1,4 @@
#include "darknet/network.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet.h"
void train_writing(char *cfgfile, char *weightfile)
{

View File

@ -1,10 +1,4 @@
#include "darknet/network.h"
#include "darknet/detection_layer.h"
#include "darknet/cost_layer.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet/box.h"
#include "darknet/demo.h"
#include "darknet.h"
char *voc_names[] = {"aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"};

538
include/darknet.h Normal file
View File

@ -0,0 +1,538 @@
#ifndef DARKNET_API
#define DARKNET_API
#include <stdlib.h>
extern int gpu_index;
#ifdef GPU
#define BLOCK 512
#include "cuda_runtime.h"
#include "curand.h"
#include "cublas_v2.h"
#ifdef CUDNN
#include "cudnn.h"
#endif
#endif
#ifndef __cplusplus
#ifdef OPENCV
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/version.hpp"
#if CV_MAJOR_VERSION == 3
#include "opencv2/videoio/videoio_c.h"
#endif
#endif
#endif
typedef struct{
int *leaf;
int n;
int *parent;
int *child;
int *group;
char **name;
int groups;
int *group_size;
int *group_offset;
} tree;
typedef enum{
LOGISTIC, RELU, RELIE, LINEAR, RAMP, TANH, PLSE, LEAKY, ELU, LOGGY, STAIR, HARDTAN, LHTAN
}ACTIVATION;
typedef enum {
CONVOLUTIONAL,
DECONVOLUTIONAL,
CONNECTED,
MAXPOOL,
SOFTMAX,
DETECTION,
DROPOUT,
CROP,
ROUTE,
COST,
NORMALIZATION,
AVGPOOL,
LOCAL,
SHORTCUT,
ACTIVE,
RNN,
GRU,
CRNN,
BATCHNORM,
NETWORK,
XNOR,
REGION,
REORG,
BLANK
} LAYER_TYPE;
typedef enum{
SSE, MASKED, L1, SMOOTH
} COST_TYPE;
struct network;
typedef struct network network;
struct layer;
typedef struct layer layer;
struct layer{
LAYER_TYPE type;
ACTIVATION activation;
COST_TYPE cost_type;
void (*forward) (struct layer, struct network);
void (*backward) (struct layer, struct network);
void (*update) (struct layer, int, float, float, float);
void (*forward_gpu) (struct layer, struct network);
void (*backward_gpu) (struct layer, struct network);
void (*update_gpu) (struct layer, int, float, float, float);
int batch_normalize;
int shortcut;
int batch;
int forced;
int flipped;
int inputs;
int outputs;
int nweights;
int nbiases;
int extra;
int truths;
int h,w,c;
int out_h, out_w, out_c;
int n;
int max_boxes;
int groups;
int size;
int side;
int stride;
int reverse;
int flatten;
int spatial;
int pad;
int sqrt;
int flip;
int index;
int binary;
int xnor;
int steps;
int hidden;
int truth;
float smooth;
float dot;
float angle;
float jitter;
float saturation;
float exposure;
float shift;
float ratio;
float learning_rate_scale;
int softmax;
int classes;
int coords;
int background;
int rescore;
int objectness;
int does_cost;
int joint;
int noadjust;
int reorg;
int log;
int adam;
float B1;
float B2;
float eps;
int t;
float alpha;
float beta;
float kappa;
float coord_scale;
float object_scale;
float noobject_scale;
float class_scale;
int bias_match;
int random;
float thresh;
int classfix;
int absolute;
int onlyforward;
int stopbackward;
int dontload;
int dontloadscales;
float temperature;
float probability;
float scale;
char * cweights;
int * indexes;
int * input_layers;
int * input_sizes;
int * map;
float * rand;
float * cost;
float * state;
float * prev_state;
float * forgot_state;
float * forgot_delta;
float * state_delta;
float * concat;
float * concat_delta;
float * binary_weights;
float * biases;
float * bias_updates;
float * scales;
float * scale_updates;
float * weights;
float * weight_updates;
float * delta;
float * output;
float * squared;
float * norms;
float * spatial_mean;
float * mean;
float * variance;
float * mean_delta;
float * variance_delta;
float * rolling_mean;
float * rolling_variance;
float * x;
float * x_norm;
float * m;
float * v;
float * bias_m;
float * bias_v;
float * scale_m;
float * scale_v;
float * z_cpu;
float * r_cpu;
float * h_cpu;
float * binary_input;
struct layer *input_layer;
struct layer *self_layer;
struct layer *output_layer;
struct layer *input_gate_layer;
struct layer *state_gate_layer;
struct layer *input_save_layer;
struct layer *state_save_layer;
struct layer *input_state_layer;
struct layer *state_state_layer;
struct layer *input_z_layer;
struct layer *state_z_layer;
struct layer *input_r_layer;
struct layer *state_r_layer;
struct layer *input_h_layer;
struct layer *state_h_layer;
tree *softmax_tree;
size_t workspace_size;
#ifdef GPU
int *indexes_gpu;
float *z_gpu;
float *r_gpu;
float *h_gpu;
float *m_gpu;
float *v_gpu;
float *bias_m_gpu;
float *scale_m_gpu;
float *bias_v_gpu;
float *scale_v_gpu;
float * prev_state_gpu;
float * forgot_state_gpu;
float * forgot_delta_gpu;
float * state_gpu;
float * state_delta_gpu;
float * gate_gpu;
float * gate_delta_gpu;
float * save_gpu;
float * save_delta_gpu;
float * concat_gpu;
float * concat_delta_gpu;
float *binary_input_gpu;
float *binary_weights_gpu;
float * mean_gpu;
float * variance_gpu;
float * rolling_mean_gpu;
float * rolling_variance_gpu;
float * variance_delta_gpu;
float * mean_delta_gpu;
float * x_gpu;
float * x_norm_gpu;
float * weights_gpu;
float * weight_updates_gpu;
float * biases_gpu;
float * bias_updates_gpu;
float * scales_gpu;
float * scale_updates_gpu;
float * output_gpu;
float * delta_gpu;
float * rand_gpu;
float * squared_gpu;
float * norms_gpu;
#ifdef CUDNN
cudnnTensorDescriptor_t srcTensorDesc, dstTensorDesc;
cudnnTensorDescriptor_t dsrcTensorDesc, ddstTensorDesc;
cudnnTensorDescriptor_t normTensorDesc;
cudnnFilterDescriptor_t weightDesc;
cudnnFilterDescriptor_t dweightDesc;
cudnnConvolutionDescriptor_t convDesc;
cudnnConvolutionFwdAlgo_t fw_algo;
cudnnConvolutionBwdDataAlgo_t bd_algo;
cudnnConvolutionBwdFilterAlgo_t bf_algo;
#endif
#endif
};
void free_layer(layer);
typedef enum {
CONSTANT, STEP, EXP, POLY, STEPS, SIG, RANDOM
} learning_rate_policy;
typedef struct network{
int n;
int batch;
int *seen;
float epoch;
int subdivisions;
float momentum;
float decay;
layer *layers;
float *output;
learning_rate_policy policy;
float learning_rate;
float gamma;
float scale;
float power;
int time_steps;
int step;
int max_batches;
float *scales;
int *steps;
int num_steps;
int burn_in;
int adam;
float B1;
float B2;
float eps;
int inputs;
int outputs;
int truths;
int notruth;
int h, w, c;
int max_crop;
int min_crop;
int center;
float angle;
float aspect;
float exposure;
float saturation;
float hue;
int gpu_index;
tree *hierarchy;
float *input;
float *truth;
float *delta;
float *workspace;
int train;
int index;
float *cost;
#ifdef GPU
float *input_gpu;
float *truth_gpu;
float *delta_gpu;
float *output_gpu;
#endif
} network;
typedef struct {
int w;
int h;
float scale;
float rad;
float dx;
float dy;
float aspect;
} augment_args;
typedef struct {
int h;
int w;
int c;
float *data;
} image;
typedef struct{
float x, y, w, h;
} box;
typedef struct matrix{
int rows, cols;
float **vals;
} matrix;
typedef struct{
int w, h;
matrix X;
matrix y;
int shallow;
int *num_boxes;
box **boxes;
} data;
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, SEGMENTATION_DATA
} data_type;
typedef struct load_args{
int threads;
char **paths;
char *path;
int n;
int m;
char **labels;
int h;
int w;
int out_w;
int out_h;
int nh;
int nw;
int num_boxes;
int min, max, size;
int classes;
int background;
int scale;
int center;
float jitter;
float angle;
float aspect;
float saturation;
float exposure;
float hue;
data *d;
image *im;
image *resized;
data_type type;
tree *hierarchy;
} load_args;
typedef struct{
int id;
float x,y,w,h;
float left, right, top, bottom;
} box_label;
network load_network(char *cfg, char *weights, int clear);
load_args get_base_args(network net);
void free_data(data d);
typedef struct node{
void *val;
struct node *next;
struct node *prev;
} node;
typedef struct list{
int size;
node *front;
node *back;
} list;
pthread_t load_data(load_args args);
list *read_data_cfg(char *filename);
list *read_cfg(char *filename);
#include "activation_layer.h"
#include "activations.h"
#include "avgpool_layer.h"
#include "batchnorm_layer.h"
#include "blas.h"
#include "box.h"
#include "classifier.h"
#include "col2im.h"
#include "connected_layer.h"
#include "convolutional_layer.h"
#include "cost_layer.h"
#include "crnn_layer.h"
#include "crop_layer.h"
#include "cuda.h"
#include "data.h"
#include "deconvolutional_layer.h"
#include "demo.h"
#include "detection_layer.h"
#include "dropout_layer.h"
#include "gemm.h"
#include "gru_layer.h"
#include "im2col.h"
#include "image.h"
#include "layer.h"
#include "list.h"
#include "local_layer.h"
#include "matrix.h"
#include "maxpool_layer.h"
#include "network.h"
#include "normalization_layer.h"
#include "option_list.h"
#include "parser.h"
#include "region_layer.h"
#include "reorg_layer.h"
#include "rnn_layer.h"
#include "route_layer.h"
#include "shortcut_layer.h"
#include "softmax_layer.h"
#include "stb_image.h"
#include "stb_image_write.h"
#include "tree.h"
#include "utils.h"
#endif

View File

@ -3,8 +3,8 @@
#include "cublas_v2.h"
extern "C" {
#include "darknet/activations.h"
#include "darknet/cuda.h"
#include "activations.h"
#include "cuda.h"
}

View File

@ -1,8 +1,8 @@
#include "darknet/activation_layer.h"
#include "darknet/utils.h"
#include "darknet/cuda.h"
#include "darknet/blas.h"
#include "darknet/gemm.h"
#include "activation_layer.h"
#include "utils.h"
#include "cuda.h"
#include "blas.h"
#include "gemm.h"
#include <math.h>
#include <stdio.h>

View File

@ -1,4 +1,4 @@
#include "darknet/activations.h"
#include "activations.h"
#include <math.h>
#include <stdio.h>

View File

@ -1,12 +1,9 @@
#ifndef ACTIVATIONS_H
#define ACTIVATIONS_H
#include "darknet.h"
#include "cuda.h"
#include "math.h"
typedef enum{
LOGISTIC, RELU, RELIE, LINEAR, RAMP, TANH, PLSE, LEAKY, ELU, LOGGY, STAIR, HARDTAN, LHTAN
}ACTIVATION;
ACTIVATION get_activation(char *s);
char *get_activation_string(ACTIVATION a);

View File

@ -1,5 +1,5 @@
#include "darknet/avgpool_layer.h"
#include "darknet/cuda.h"
#include "avgpool_layer.h"
#include "cuda.h"
#include <stdio.h>
avgpool_layer make_avgpool_layer(int batch, int w, int h, int c)

View File

@ -3,8 +3,8 @@
#include "cublas_v2.h"
extern "C" {
#include "darknet/avgpool_layer.h"
#include "darknet/cuda.h"
#include "avgpool_layer.h"
#include "cuda.h"
}
__global__ void forward_avgpool_layer_kernel(int n, int w, int h, int c, float *input, float *output)

View File

@ -1,6 +1,6 @@
#include "darknet/convolutional_layer.h"
#include "darknet/batchnorm_layer.h"
#include "darknet/blas.h"
#include "convolutional_layer.h"
#include "batchnorm_layer.h"
#include "blas.h"
#include <stdio.h>
layer make_batchnorm_layer(int batch, int w, int h, int c)

View File

@ -1,4 +1,4 @@
#include "darknet/blas.h"
#include "blas.h"
#include <math.h>
#include <assert.h>

View File

@ -18,7 +18,7 @@ void copy_cpu(int N, float *X, int INCX, float *Y, int INCY);
void scal_cpu(int N, float ALPHA, float *X, int INCX);
void fill_cpu(int N, float ALPHA, float * X, int INCX);
float dot_cpu(int N, float *X, int INCX, float *Y, int INCY);
void test_gpu_blas();
int test_gpu_blas();
void shortcut_cpu(int batch, int w1, int h1, int c1, float *add, int w2, int h2, int c2, float *out);
void mean_cpu(float *x, int batch, int filters, int spatial, float *mean);

View File

@ -4,9 +4,9 @@
#include <assert.h>
extern "C" {
#include "darknet/blas.h"
#include "darknet/cuda.h"
#include "darknet/utils.h"
#include "blas.h"
#include "cuda.h"
#include "utils.h"
}
__global__ void scale_bias_kernel(float *output, float *biases, int n, int size)

View File

@ -1,4 +1,4 @@
#include "darknet/box.h"
#include "box.h"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

View File

@ -1,9 +1,6 @@
#ifndef BOX_H
#define BOX_H
typedef struct{
float x, y, w, h;
} box;
#include "darknet.h"
typedef struct{
float dx, dy, dw, dh;

View File

@ -1,2 +1 @@
list *read_data_cfg(char *filename);

View File

@ -3,8 +3,8 @@
#include "cublas_v2.h"
extern "C" {
#include "darknet/col2im.h"
#include "darknet/cuda.h"
#include "col2im.h"
#include "cuda.h"
}
// src: https://github.com/BVLC/caffe/blob/master/src/caffe/util/im2col.cu

View File

@ -1,11 +1,11 @@
#include <stdio.h>
#include "darknet/network.h"
#include "darknet/detection_layer.h"
#include "darknet/cost_layer.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet/box.h"
#include "network.h"
#include "detection_layer.h"
#include "cost_layer.h"
#include "utils.h"
#include "parser.h"
#include "box.h"
void train_compare(char *cfgfile, char *weightfile)
{

View File

@ -1,9 +1,9 @@
#include "darknet/connected_layer.h"
#include "darknet/batchnorm_layer.h"
#include "darknet/utils.h"
#include "darknet/cuda.h"
#include "darknet/blas.h"
#include "darknet/gemm.h"
#include "connected_layer.h"
#include "batchnorm_layer.h"
#include "utils.h"
#include "cuda.h"
#include "blas.h"
#include "gemm.h"
#include <math.h>
#include <stdio.h>

View File

@ -3,14 +3,14 @@
#include "cublas_v2.h"
extern "C" {
#include "darknet/convolutional_layer.h"
#include "darknet/batchnorm_layer.h"
#include "darknet/gemm.h"
#include "darknet/blas.h"
#include "darknet/im2col.h"
#include "darknet/col2im.h"
#include "darknet/utils.h"
#include "darknet/cuda.h"
#include "convolutional_layer.h"
#include "batchnorm_layer.h"
#include "gemm.h"
#include "blas.h"
#include "im2col.h"
#include "col2im.h"
#include "utils.h"
#include "cuda.h"
}
__global__ void binarize_kernel(float *x, int n, float *binary)

View File

@ -1,10 +1,10 @@
#include "darknet/convolutional_layer.h"
#include "darknet/utils.h"
#include "darknet/batchnorm_layer.h"
#include "darknet/im2col.h"
#include "darknet/col2im.h"
#include "darknet/blas.h"
#include "darknet/gemm.h"
#include "convolutional_layer.h"
#include "utils.h"
#include "batchnorm_layer.h"
#include "im2col.h"
#include "col2im.h"
#include "blas.h"
#include "gemm.h"
#include <stdio.h>
#include <time.h>

View File

@ -1,7 +1,7 @@
#include "darknet/cost_layer.h"
#include "darknet/utils.h"
#include "darknet/cuda.h"
#include "darknet/blas.h"
#include "cost_layer.h"
#include "utils.h"
#include "cuda.h"
#include "blas.h"
#include <math.h>
#include <string.h>
#include <stdlib.h>

View File

@ -1,9 +1,9 @@
#include "darknet/crnn_layer.h"
#include "darknet/convolutional_layer.h"
#include "darknet/utils.h"
#include "darknet/cuda.h"
#include "darknet/blas.h"
#include "darknet/gemm.h"
#include "crnn_layer.h"
#include "convolutional_layer.h"
#include "utils.h"
#include "cuda.h"
#include "blas.h"
#include "gemm.h"
#include <math.h>
#include <stdio.h>

View File

@ -1,5 +1,5 @@
#include "darknet/crop_layer.h"
#include "darknet/cuda.h"
#include "crop_layer.h"
#include "cuda.h"
#include <stdio.h>
image get_crop_image(crop_layer l)

View File

@ -3,10 +3,10 @@
#include "cublas_v2.h"
extern "C" {
#include "darknet/crop_layer.h"
#include "darknet/utils.h"
#include "darknet/cuda.h"
#include "darknet/image.h"
#include "crop_layer.h"
#include "utils.h"
#include "cuda.h"
#include "image.h"
}
__device__ float get_pixel_kernel(float *image, int w, int h, int x, int y, int c)

View File

@ -2,9 +2,9 @@ int gpu_index = 0;
#ifdef GPU
#include "darknet/cuda.h"
#include "darknet/utils.h"
#include "darknet/blas.h"
#include "cuda.h"
#include "utils.h"
#include "blas.h"
#include <assert.h>
#include <stdlib.h>
#include <time.h>

View File

@ -1,20 +1,10 @@
#ifndef CUDA_H
#define CUDA_H
extern int gpu_index;
#include "darknet.h"
#ifdef GPU
#define BLOCK 512
#include "cuda_runtime.h"
#include "curand.h"
#include "cublas_v2.h"
#ifdef CUDNN
#include "cudnn.h"
#endif
void check_error(cudaError_t status);
cublasHandle_t blas_handle();
float *cuda_make_array(float *x, size_t n);

View File

@ -1,7 +1,7 @@
#include "darknet/data.h"
#include "darknet/utils.h"
#include "darknet/image.h"
#include "darknet/cuda.h"
#include "data.h"
#include "utils.h"
#include "image.h"
#include "cuda.h"
#include <stdio.h>
#include <stdlib.h>

View File

@ -2,6 +2,7 @@
#define DATA_H
#include <pthread.h>
#include "darknet.h"
#include "matrix.h"
#include "list.h"
#include "image.h"
@ -17,61 +18,6 @@ static inline float distance_from_edge(int x, int max)
if (dist > 1) dist = 1;
return dist;
}
typedef struct{
int w, h;
matrix X;
matrix y;
int shallow;
int *num_boxes;
box **boxes;
} data;
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, SEGMENTATION_DATA
} data_type;
typedef struct load_args{
int threads;
char **paths;
char *path;
int n;
int m;
char **labels;
int h;
int w;
int out_w;
int out_h;
int nh;
int nw;
int num_boxes;
int min, max, size;
int classes;
int background;
int scale;
int center;
float jitter;
float angle;
float aspect;
float saturation;
float exposure;
float hue;
data *d;
image *im;
image *resized;
data_type type;
tree *hierarchy;
} load_args;
typedef struct{
int id;
float x,y,w,h;
float left, right, top, bottom;
} box_label;
void free_data(data d);
pthread_t load_data(load_args args);
void load_data_blocking(load_args args);
pthread_t load_data_in_thread(load_args args);

View File

@ -3,15 +3,15 @@
#include "cublas_v2.h"
extern "C" {
#include "darknet/convolutional_layer.h"
#include "darknet/deconvolutional_layer.h"
#include "darknet/batchnorm_layer.h"
#include "darknet/gemm.h"
#include "darknet/blas.h"
#include "darknet/im2col.h"
#include "darknet/col2im.h"
#include "darknet/utils.h"
#include "darknet/cuda.h"
#include "convolutional_layer.h"
#include "deconvolutional_layer.h"
#include "batchnorm_layer.h"
#include "gemm.h"
#include "blas.h"
#include "im2col.h"
#include "col2im.h"
#include "utils.h"
#include "cuda.h"
}
extern "C" void forward_deconvolutional_layer_gpu(layer l, network net)

View File

@ -1,11 +1,11 @@
#include "darknet/deconvolutional_layer.h"
#include "darknet/convolutional_layer.h"
#include "darknet/batchnorm_layer.h"
#include "darknet/utils.h"
#include "darknet/im2col.h"
#include "darknet/col2im.h"
#include "darknet/blas.h"
#include "darknet/gemm.h"
#include "deconvolutional_layer.h"
#include "convolutional_layer.h"
#include "batchnorm_layer.h"
#include "utils.h"
#include "im2col.h"
#include "col2im.h"
#include "blas.h"
#include "gemm.h"
#include <stdio.h>
#include <time.h>

View File

@ -1,12 +1,12 @@
#include "darknet/network.h"
#include "darknet/detection_layer.h"
#include "darknet/region_layer.h"
#include "darknet/cost_layer.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "darknet/box.h"
#include "darknet/image.h"
#include "darknet/demo.h"
#include "network.h"
#include "detection_layer.h"
#include "region_layer.h"
#include "cost_layer.h"
#include "utils.h"
#include "parser.h"
#include "box.h"
#include "image.h"
#include "demo.h"
#include <sys/time.h>
#define DEMO 1
@ -31,7 +31,7 @@ static float demo_hier = .5;
static int running = 0;
static int demo_delay = 0;
static int demo_frame = 5;
static int demo_frame = 3;
static int demo_detections = 0;
static float **predictions;
static int demo_index = 0;

View File

@ -1,10 +1,10 @@
#include "darknet/detection_layer.h"
#include "darknet/activations.h"
#include "darknet/softmax_layer.h"
#include "darknet/blas.h"
#include "darknet/box.h"
#include "darknet/cuda.h"
#include "darknet/utils.h"
#include "detection_layer.h"
#include "activations.h"
#include "softmax_layer.h"
#include "blas.h"
#include "box.h"
#include "cuda.h"
#include "utils.h"
#include <stdio.h>
#include <assert.h>

View File

@ -1,6 +1,6 @@
#include "darknet/dropout_layer.h"
#include "darknet/utils.h"
#include "darknet/cuda.h"
#include "dropout_layer.h"
#include "utils.h"
#include "cuda.h"
#include <stdlib.h>
#include <stdio.h>

View File

@ -3,9 +3,9 @@
#include "cublas_v2.h"
extern "C" {
#include "darknet/dropout_layer.h"
#include "darknet/cuda.h"
#include "darknet/utils.h"
#include "dropout_layer.h"
#include "cuda.h"
#include "utils.h"
}
__global__ void yoloswag420blazeit360noscope(float *input, int size, float *rand, float prob, float scale)

View File

@ -1,6 +1,6 @@
#include "darknet/gemm.h"
#include "darknet/utils.h"
#include "darknet/cuda.h"
#include "gemm.h"
#include "utils.h"
#include "cuda.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

View File

@ -1,9 +1,9 @@
#include "darknet/gru_layer.h"
#include "darknet/connected_layer.h"
#include "darknet/utils.h"
#include "darknet/cuda.h"
#include "darknet/blas.h"
#include "darknet/gemm.h"
#include "gru_layer.h"
#include "connected_layer.h"
#include "utils.h"
#include "cuda.h"
#include "blas.h"
#include "gemm.h"
#include <math.h>
#include <stdio.h>

View File

@ -1,4 +1,4 @@
#include "darknet/im2col.h"
#include "im2col.h"
#include <stdio.h>
float im2col_get_pixel(float *im, int height, int width, int channels,
int row, int col, int channel, int pad)

View File

@ -3,8 +3,8 @@
#include "cublas_v2.h"
extern "C" {
#include "darknet/im2col.h"
#include "darknet/cuda.h"
#include "im2col.h"
#include "cuda.h"
}
// src: https://github.com/BVLC/caffe/blob/master/src/caffe/util/im2col.cu

View File

@ -1,14 +1,14 @@
#include "darknet/image.h"
#include "darknet/utils.h"
#include "darknet/blas.h"
#include "darknet/cuda.h"
#include "image.h"
#include "utils.h"
#include "blas.h"
#include "cuda.h"
#include <stdio.h>
#include <math.h>
#define STB_IMAGE_IMPLEMENTATION
#include "darknet/stb_image.h"
#include "stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "darknet/stb_image_write.h"
#include "stb_image_write.h"
int windows = 0;

View File

@ -7,34 +7,7 @@
#include <string.h>
#include <math.h>
#include "box.h"
#ifndef __cplusplus
#ifdef OPENCV
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/version.hpp"
#if CV_MAJOR_VERSION == 3
#include "opencv2/videoio/videoio_c.h"
#endif
#endif
#endif
typedef struct {
int w;
int h;
float scale;
float rad;
float dx;
float dy;
float aspect;
} augment_args;
typedef struct {
int h;
int w;
int c;
float *data;
} image;
#include "darknet.h"
#ifndef __cplusplus
#ifdef OPENCV

View File

@ -1,5 +1,5 @@
#include "darknet/layer.h"
#include "darknet/cuda.h"
#include "layer.h"
#include "cuda.h"
#include <stdlib.h>

View File

@ -1,289 +1 @@
#ifndef BASE_LAYER_H
#define BASE_LAYER_H
#include "activations.h"
#include "stddef.h"
#include "tree.h"
struct network;
typedef struct network network;
struct layer;
typedef struct layer layer;
typedef enum {
CONVOLUTIONAL,
DECONVOLUTIONAL,
CONNECTED,
MAXPOOL,
SOFTMAX,
DETECTION,
DROPOUT,
CROP,
ROUTE,
COST,
NORMALIZATION,
AVGPOOL,
LOCAL,
SHORTCUT,
ACTIVE,
RNN,
GRU,
CRNN,
BATCHNORM,
NETWORK,
XNOR,
REGION,
REORG,
BLANK
} LAYER_TYPE;
typedef enum{
SSE, MASKED, L1, SMOOTH
} COST_TYPE;
struct layer{
LAYER_TYPE type;
ACTIVATION activation;
COST_TYPE cost_type;
void (*forward) (struct layer, struct network);
void (*backward) (struct layer, struct network);
void (*update) (struct layer, int, float, float, float);
void (*forward_gpu) (struct layer, struct network);
void (*backward_gpu) (struct layer, struct network);
void (*update_gpu) (struct layer, int, float, float, float);
int batch_normalize;
int shortcut;
int batch;
int forced;
int flipped;
int inputs;
int outputs;
int nweights;
int nbiases;
int extra;
int truths;
int h,w,c;
int out_h, out_w, out_c;
int n;
int max_boxes;
int groups;
int size;
int side;
int stride;
int reverse;
int flatten;
int spatial;
int pad;
int sqrt;
int flip;
int index;
int binary;
int xnor;
int steps;
int hidden;
int truth;
float smooth;
float dot;
float angle;
float jitter;
float saturation;
float exposure;
float shift;
float ratio;
float learning_rate_scale;
int softmax;
int classes;
int coords;
int background;
int rescore;
int objectness;
int does_cost;
int joint;
int noadjust;
int reorg;
int log;
int adam;
float B1;
float B2;
float eps;
int t;
float alpha;
float beta;
float kappa;
float coord_scale;
float object_scale;
float noobject_scale;
float class_scale;
int bias_match;
int random;
float thresh;
int classfix;
int absolute;
int onlyforward;
int stopbackward;
int dontload;
int dontloadscales;
float temperature;
float probability;
float scale;
char * cweights;
int * indexes;
int * input_layers;
int * input_sizes;
int * map;
float * rand;
float * cost;
float * state;
float * prev_state;
float * forgot_state;
float * forgot_delta;
float * state_delta;
float * concat;
float * concat_delta;
float * binary_weights;
float * biases;
float * bias_updates;
float * scales;
float * scale_updates;
float * weights;
float * weight_updates;
float * delta;
float * output;
float * squared;
float * norms;
float * spatial_mean;
float * mean;
float * variance;
float * mean_delta;
float * variance_delta;
float * rolling_mean;
float * rolling_variance;
float * x;
float * x_norm;
float * m;
float * v;
float * bias_m;
float * bias_v;
float * scale_m;
float * scale_v;
float * z_cpu;
float * r_cpu;
float * h_cpu;
float * binary_input;
struct layer *input_layer;
struct layer *self_layer;
struct layer *output_layer;
struct layer *input_gate_layer;
struct layer *state_gate_layer;
struct layer *input_save_layer;
struct layer *state_save_layer;
struct layer *input_state_layer;
struct layer *state_state_layer;
struct layer *input_z_layer;
struct layer *state_z_layer;
struct layer *input_r_layer;
struct layer *state_r_layer;
struct layer *input_h_layer;
struct layer *state_h_layer;
tree *softmax_tree;
size_t workspace_size;
#ifdef GPU
int *indexes_gpu;
float *z_gpu;
float *r_gpu;
float *h_gpu;
float *m_gpu;
float *v_gpu;
float *bias_m_gpu;
float *scale_m_gpu;
float *bias_v_gpu;
float *scale_v_gpu;
float * prev_state_gpu;
float * forgot_state_gpu;
float * forgot_delta_gpu;
float * state_gpu;
float * state_delta_gpu;
float * gate_gpu;
float * gate_delta_gpu;
float * save_gpu;
float * save_delta_gpu;
float * concat_gpu;
float * concat_delta_gpu;
float *binary_input_gpu;
float *binary_weights_gpu;
float * mean_gpu;
float * variance_gpu;
float * rolling_mean_gpu;
float * rolling_variance_gpu;
float * variance_delta_gpu;
float * mean_delta_gpu;
float * x_gpu;
float * x_norm_gpu;
float * weights_gpu;
float * weight_updates_gpu;
float * biases_gpu;
float * bias_updates_gpu;
float * scales_gpu;
float * scale_updates_gpu;
float * output_gpu;
float * delta_gpu;
float * rand_gpu;
float * squared_gpu;
float * norms_gpu;
#ifdef CUDNN
cudnnTensorDescriptor_t srcTensorDesc, dstTensorDesc;
cudnnTensorDescriptor_t dsrcTensorDesc, ddstTensorDesc;
cudnnTensorDescriptor_t normTensorDesc;
cudnnFilterDescriptor_t weightDesc;
cudnnFilterDescriptor_t dweightDesc;
cudnnConvolutionDescriptor_t convDesc;
cudnnConvolutionFwdAlgo_t fw_algo;
cudnnConvolutionBwdDataAlgo_t bd_algo;
cudnnConvolutionBwdFilterAlgo_t bf_algo;
#endif
#endif
};
void free_layer(layer);
#endif
#include "darknet.h"

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include <string.h>
#include "darknet/list.h"
#include "list.h"
list *make_list()
{

View File

@ -1,17 +1,6 @@
#ifndef LIST_H
#define LIST_H
typedef struct node{
void *val;
struct node *next;
struct node *prev;
} node;
typedef struct list{
int size;
node *front;
node *back;
} list;
#include "darknet.h"
list *make_list();
int list_find(list *l, void *val);

View File

@ -1,9 +1,9 @@
#include "darknet/local_layer.h"
#include "darknet/utils.h"
#include "darknet/im2col.h"
#include "darknet/col2im.h"
#include "darknet/blas.h"
#include "darknet/gemm.h"
#include "local_layer.h"
#include "utils.h"
#include "im2col.h"
#include "col2im.h"
#include "blas.h"
#include "gemm.h"
#include <stdio.h>
#include <time.h>

View File

@ -1,6 +1,6 @@
#include "darknet/matrix.h"
#include "darknet/utils.h"
#include "darknet/blas.h"
#include "matrix.h"
#include "utils.h"
#include "blas.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -1,9 +1,6 @@
#ifndef MATRIX_H
#define MATRIX_H
typedef struct matrix{
int rows, cols;
float **vals;
} matrix;
#include "darknet.h"
matrix make_matrix(int rows, int cols);
matrix copy_matrix(matrix m);

View File

@ -1,5 +1,5 @@
#include "darknet/maxpool_layer.h"
#include "darknet/cuda.h"
#include "maxpool_layer.h"
#include "cuda.h"
#include <stdio.h>
image get_maxpool_image(maxpool_layer l)

View File

@ -3,8 +3,8 @@
#include "cublas_v2.h"
extern "C" {
#include "darknet/maxpool_layer.h"
#include "darknet/cuda.h"
#include "maxpool_layer.h"
#include "cuda.h"
}
__global__ void forward_maxpool_layer_kernel(int n, int in_h, int in_w, int in_c, int stride, int size, int pad, float *input, float *output, int *indexes)

View File

@ -1,34 +1,34 @@
#include <stdio.h>
#include <time.h>
#include <assert.h>
#include "darknet/network.h"
#include "darknet/image.h"
#include "darknet/data.h"
#include "darknet/utils.h"
#include "darknet/blas.h"
#include "network.h"
#include "image.h"
#include "data.h"
#include "utils.h"
#include "blas.h"
#include "darknet/crop_layer.h"
#include "darknet/connected_layer.h"
#include "darknet/gru_layer.h"
#include "darknet/rnn_layer.h"
#include "darknet/crnn_layer.h"
#include "darknet/local_layer.h"
#include "darknet/convolutional_layer.h"
#include "darknet/activation_layer.h"
#include "darknet/detection_layer.h"
#include "darknet/region_layer.h"
#include "darknet/normalization_layer.h"
#include "darknet/batchnorm_layer.h"
#include "darknet/maxpool_layer.h"
#include "darknet/reorg_layer.h"
#include "darknet/avgpool_layer.h"
#include "darknet/cost_layer.h"
#include "darknet/softmax_layer.h"
#include "darknet/dropout_layer.h"
#include "darknet/route_layer.h"
#include "darknet/shortcut_layer.h"
#include "darknet/parser.h"
#include "darknet/data.h"
#include "crop_layer.h"
#include "connected_layer.h"
#include "gru_layer.h"
#include "rnn_layer.h"
#include "crnn_layer.h"
#include "local_layer.h"
#include "convolutional_layer.h"
#include "activation_layer.h"
#include "detection_layer.h"
#include "region_layer.h"
#include "normalization_layer.h"
#include "batchnorm_layer.h"
#include "maxpool_layer.h"
#include "reorg_layer.h"
#include "avgpool_layer.h"
#include "cost_layer.h"
#include "softmax_layer.h"
#include "dropout_layer.h"
#include "route_layer.h"
#include "shortcut_layer.h"
#include "parser.h"
#include "data.h"
load_args get_base_args(network net)
{

View File

@ -1,81 +1,13 @@
// Oh boy, why am I about to do this....
#ifndef NETWORK_H
#define NETWORK_H
#include "darknet.h"
#include "image.h"
#include "layer.h"
#include "data.h"
#include "tree.h"
typedef enum {
CONSTANT, STEP, EXP, POLY, STEPS, SIG, RANDOM
} learning_rate_policy;
typedef struct network{
int n;
int batch;
int *seen;
float epoch;
int subdivisions;
float momentum;
float decay;
layer *layers;
float *output;
learning_rate_policy policy;
float learning_rate;
float gamma;
float scale;
float power;
int time_steps;
int step;
int max_batches;
float *scales;
int *steps;
int num_steps;
int burn_in;
int adam;
float B1;
float B2;
float eps;
int inputs;
int outputs;
int truths;
int notruth;
int h, w, c;
int max_crop;
int min_crop;
int center;
float angle;
float aspect;
float exposure;
float saturation;
float hue;
int gpu_index;
tree *hierarchy;
float *input;
float *truth;
float *delta;
float *workspace;
int train;
int index;
float *cost;
#ifdef GPU
float *input_gpu;
float *truth_gpu;
float *delta_gpu;
float *output_gpu;
#endif
} network;
#ifdef GPU
float train_networks(network *nets, int n, data d, int interval);
@ -118,8 +50,6 @@ void print_network(network net);
void visualize_network(network net);
int resize_network(network *net, int w, int h);
void set_batch_network(network *net, int b);
network load_network(char *cfg, char *weights, int clear);
load_args get_base_args(network net);
void calc_network_cost(network net);
#endif

View File

@ -7,32 +7,32 @@ extern "C" {
#include <time.h>
#include <assert.h>
#include "darknet/network.h"
#include "darknet/data.h"
#include "darknet/utils.h"
#include "darknet/parser.h"
#include "network.h"
#include "data.h"
#include "utils.h"
#include "parser.h"
#include "darknet/crop_layer.h"
#include "darknet/connected_layer.h"
#include "darknet/rnn_layer.h"
#include "darknet/gru_layer.h"
#include "darknet/crnn_layer.h"
#include "darknet/detection_layer.h"
#include "darknet/region_layer.h"
#include "darknet/convolutional_layer.h"
#include "darknet/activation_layer.h"
#include "darknet/maxpool_layer.h"
#include "darknet/reorg_layer.h"
#include "darknet/avgpool_layer.h"
#include "darknet/normalization_layer.h"
#include "darknet/batchnorm_layer.h"
#include "darknet/cost_layer.h"
#include "darknet/local_layer.h"
#include "darknet/softmax_layer.h"
#include "darknet/dropout_layer.h"
#include "darknet/route_layer.h"
#include "darknet/shortcut_layer.h"
#include "darknet/blas.h"
#include "crop_layer.h"
#include "connected_layer.h"
#include "rnn_layer.h"
#include "gru_layer.h"
#include "crnn_layer.h"
#include "detection_layer.h"
#include "region_layer.h"
#include "convolutional_layer.h"
#include "activation_layer.h"
#include "maxpool_layer.h"
#include "reorg_layer.h"
#include "avgpool_layer.h"
#include "normalization_layer.h"
#include "batchnorm_layer.h"
#include "cost_layer.h"
#include "local_layer.h"
#include "softmax_layer.h"
#include "dropout_layer.h"
#include "route_layer.h"
#include "shortcut_layer.h"
#include "blas.h"
}
void forward_network_gpu(network net)

View File

@ -1,5 +1,5 @@
#include "darknet/normalization_layer.h"
#include "darknet/blas.h"
#include "normalization_layer.h"
#include "blas.h"
#include <stdio.h>

View File

@ -1,8 +1,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "darknet/option_list.h"
#include "darknet/utils.h"
#include "option_list.h"
#include "utils.h"
list *read_data_cfg(char *filename)
{

View File

@ -9,7 +9,6 @@ typedef struct{
} kvp;
list *read_data_cfg(char *filename);
int read_option(char *s, list *options);
void option_insert(list *l, char *key, char *val);
char *option_find(list *l, char *key);

View File

@ -3,33 +3,33 @@
#include <stdlib.h>
#include <assert.h>
#include "darknet/activation_layer.h"
#include "darknet/activations.h"
#include "darknet/avgpool_layer.h"
#include "darknet/batchnorm_layer.h"
#include "darknet/blas.h"
#include "darknet/connected_layer.h"
#include "darknet/deconvolutional_layer.h"
#include "darknet/convolutional_layer.h"
#include "darknet/cost_layer.h"
#include "darknet/crnn_layer.h"
#include "darknet/crop_layer.h"
#include "darknet/detection_layer.h"
#include "darknet/dropout_layer.h"
#include "darknet/gru_layer.h"
#include "darknet/list.h"
#include "darknet/local_layer.h"
#include "darknet/maxpool_layer.h"
#include "darknet/normalization_layer.h"
#include "darknet/option_list.h"
#include "darknet/parser.h"
#include "darknet/region_layer.h"
#include "darknet/reorg_layer.h"
#include "darknet/rnn_layer.h"
#include "darknet/route_layer.h"
#include "darknet/shortcut_layer.h"
#include "darknet/softmax_layer.h"
#include "darknet/utils.h"
#include "activation_layer.h"
#include "activations.h"
#include "avgpool_layer.h"
#include "batchnorm_layer.h"
#include "blas.h"
#include "connected_layer.h"
#include "deconvolutional_layer.h"
#include "convolutional_layer.h"
#include "cost_layer.h"
#include "crnn_layer.h"
#include "crop_layer.h"
#include "detection_layer.h"
#include "dropout_layer.h"
#include "gru_layer.h"
#include "list.h"
#include "local_layer.h"
#include "maxpool_layer.h"
#include "normalization_layer.h"
#include "option_list.h"
#include "parser.h"
#include "region_layer.h"
#include "reorg_layer.h"
#include "rnn_layer.h"
#include "route_layer.h"
#include "shortcut_layer.h"
#include "softmax_layer.h"
#include "utils.h"
typedef struct{
char *type;
@ -760,7 +760,7 @@ list *read_cfg(char *filename)
if(file == 0) file_error(filename);
char *line;
int nu = 0;
list *sections = make_list();
list *options = make_list();
section *current = 0;
while((line=fgetl(file)) != 0){
++ nu;
@ -768,7 +768,7 @@ list *read_cfg(char *filename)
switch(line[0]){
case '[':
current = malloc(sizeof(section));
list_insert(sections, current);
list_insert(options, current);
current->options = make_list();
current->type = line;
break;
@ -786,7 +786,7 @@ list *read_cfg(char *filename)
}
}
fclose(file);
return sections;
return options;
}
void save_convolutional_weights_binary(layer l, FILE *fp)

View File

@ -1,9 +1,9 @@
#include "darknet/region_layer.h"
#include "darknet/activations.h"
#include "darknet/blas.h"
#include "darknet/box.h"
#include "darknet/cuda.h"
#include "darknet/utils.h"
#include "region_layer.h"
#include "activations.h"
#include "blas.h"
#include "box.h"
#include "cuda.h"
#include "utils.h"
#include <stdio.h>
#include <assert.h>
@ -448,15 +448,65 @@ void forward_region_layer_gpu(const layer l, network net)
int index = entry_index(l, 0, 0, 5);
softmax_tree(net.input_gpu + index, l.w*l.h, l.batch*l.n, l.inputs/l.n, 1, l.output_gpu + index, *l.softmax_tree);
/*
// TIMING CODE
int zz;
int number = 1000;
int count = 0;
int i;
int count = 5;
for (i = 0; i < l.softmax_tree->groups; ++i) {
int group_size = l.softmax_tree->group_size[i];
int index = entry_index(l, 0, 0, count);
softmax_gpu(net.input_gpu + index, group_size, l.batch*l.n, l.inputs/l.n, l.w*l.h, 1, l.w*l.h, 1, l.output_gpu + index);
count += group_size;
}
printf("%d %d\n", l.softmax_tree->groups, count);
{
double then = what_time_is_it_now();
for(zz = 0; zz < number; ++zz){
int index = entry_index(l, 0, 0, 5);
softmax_tree(net.input_gpu + index, l.w*l.h, l.batch*l.n, l.inputs/l.n, 1, l.output_gpu + index, *l.softmax_tree);
}
cudaDeviceSynchronize();
printf("Good GPU Timing: %f\n", what_time_is_it_now() - then);
}
{
double then = what_time_is_it_now();
for(zz = 0; zz < number; ++zz){
int i;
int count = 5;
for (i = 0; i < l.softmax_tree->groups; ++i) {
int group_size = l.softmax_tree->group_size[i];
int index = entry_index(l, 0, 0, count);
softmax_gpu(net.input_gpu + index, group_size, l.batch*l.n, l.inputs/l.n, l.w*l.h, 1, l.w*l.h, 1, l.output_gpu + index);
count += group_size;
}
}
cudaDeviceSynchronize();
printf("Bad GPU Timing: %f\n", what_time_is_it_now() - then);
}
{
double then = what_time_is_it_now();
for(zz = 0; zz < number; ++zz){
int i;
int count = 5;
for (i = 0; i < l.softmax_tree->groups; ++i) {
int group_size = l.softmax_tree->group_size[i];
softmax_cpu(net.input + count, group_size, l.batch, l.inputs, l.n*l.w*l.h, 1, l.n*l.w*l.h, l.temperature, l.output + count);
count += group_size;
}
}
cudaDeviceSynchronize();
printf("CPU Timing: %f\n", what_time_is_it_now() - then);
}
*/
/*
int i;
int count = 5;
for (i = 0; i < l.softmax_tree->groups; ++i) {
int group_size = l.softmax_tree->group_size[i];
int index = entry_index(l, 0, 0, count);
softmax_gpu(net.input_gpu + index, group_size, l.batch*l.n, l.inputs/l.n, l.w*l.h, 1, l.w*l.h, 1, l.output_gpu + index);
count += group_size;
}
*/
} else if (l.softmax) {
int index = entry_index(l, 0, 0, l.coords + !l.background);
//printf("%d\n", index);

View File

@ -1,6 +1,6 @@
#include "darknet/reorg_layer.h"
#include "darknet/cuda.h"
#include "darknet/blas.h"
#include "reorg_layer.h"
#include "cuda.h"
#include "blas.h"
#include <stdio.h>

View File

@ -1,9 +1,9 @@
#include "darknet/rnn_layer.h"
#include "darknet/connected_layer.h"
#include "darknet/utils.h"
#include "darknet/cuda.h"
#include "darknet/blas.h"
#include "darknet/gemm.h"
#include "rnn_layer.h"
#include "connected_layer.h"
#include "utils.h"
#include "cuda.h"
#include "blas.h"
#include "gemm.h"
#include <math.h>
#include <stdio.h>

View File

@ -1,6 +1,6 @@
#include "darknet/route_layer.h"
#include "darknet/cuda.h"
#include "darknet/blas.h"
#include "route_layer.h"
#include "cuda.h"
#include "blas.h"
#include <stdio.h>

View File

@ -1,6 +1,7 @@
#include "darknet/shortcut_layer.h"
#include "darknet/cuda.h"
#include "darknet/blas.h"
#include "shortcut_layer.h"
#include "cuda.h"
#include "blas.h"
#include "activations.h"
#include <stdio.h>
#include <assert.h>

View File

@ -1,6 +1,6 @@
#include "darknet/softmax_layer.h"
#include "darknet/blas.h"
#include "darknet/cuda.h"
#include "softmax_layer.h"
#include "blas.h"
#include "cuda.h"
#include <float.h>
#include <math.h>

View File

@ -1,8 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
#include "darknet/tree.h"
#include "darknet/utils.h"
#include "darknet/data.h"
#include "tree.h"
#include "utils.h"
#include "data.h"
void change_leaves(tree *t, char *leaf_list)
{

View File

@ -1,18 +1,6 @@
#ifndef TREE_H
#define TREE_H
typedef struct{
int *leaf;
int n;
int *parent;
int *child;
int *group;
char **name;
int groups;
int *group_size;
int *group_offset;
} tree;
#include "darknet.h"
tree *read_tree(char *filename);
void hierarchy_predictions(float *predictions, int n, tree *hier, int only_leaves, int stride);

View File

@ -6,8 +6,16 @@
#include <unistd.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#include "darknet/utils.h"
#include "utils.h"
double what_time_is_it_now()
{
struct timespec now;
clock_gettime(CLOCK_REALTIME, &now);
return now.tv_sec + now.tv_nsec*1e-9;
}
int *read_intlist(char *gpu_list, int *ngpus, int d)
{
@ -608,13 +616,13 @@ float rand_normal()
size_t rand_size_t()
{
return ((size_t)(rand()&0xff) << 56) |
((size_t)(rand()&0xff) << 48) |
((size_t)(rand()&0xff) << 40) |
((size_t)(rand()&0xff) << 32) |
((size_t)(rand()&0xff) << 24) |
((size_t)(rand()&0xff) << 16) |
((size_t)(rand()&0xff) << 8) |
((size_t)(rand()&0xff) << 0);
((size_t)(rand()&0xff) << 48) |
((size_t)(rand()&0xff) << 40) |
((size_t)(rand()&0xff) << 32) |
((size_t)(rand()&0xff) << 24) |
((size_t)(rand()&0xff) << 16) |
((size_t)(rand()&0xff) << 8) |
((size_t)(rand()&0xff) << 0);
}
float rand_uniform(float min, float max)

View File

@ -7,6 +7,7 @@
#define SECRET_NUM -1234
#define TWO_PI 6.2831853071795864769252866
double what_time_is_it_now();
int *read_intlist(char *s, int *n, int d);
int *read_map(char *filename);
void shuffle(void *arr, size_t n, size_t size);