Skip to content

Commit

Permalink
NIPS
Browse files Browse the repository at this point in the history
  • Loading branch information
pjreddie committed Jun 10, 2015
1 parent 7fe80a2 commit cbc9984
Show file tree
Hide file tree
Showing 21 changed files with 7,422 additions and 752 deletions.
19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
GPU=1
OPENCV=1
DEBUG=0

ARCH= -arch=sm_52

VPATH=./src/
Expand All @@ -9,19 +11,26 @@ OBJDIR=./obj/
CC=gcc
NVCC=nvcc
OPTS=-Ofast
LDFLAGS=`pkg-config --libs opencv` -lm -pthread -lstdc++
COMMON=`pkg-config --cflags opencv` -I/usr/local/cuda/include/
CFLAGS=-Wall -Wfatal-errors
LDFLAGS= -lm -pthread -lstdc++
COMMON= -I/usr/local/cuda/include/
CFLAGS=-Wall -Wfatal-errors

ifeq ($(DEBUG), 1)
OPTS=-O0 -g
endif

CFLAGS+=$(OPTS)

ifeq ($(OPENCV), 1)
COMMON+= -DOPENCV
CFLAGS+= -DOPENCV
LDFLAGS+= `pkg-config --libs opencv`
COMMON+= `pkg-config --cflags opencv`
endif

ifeq ($(GPU), 1)
COMMON+=-DGPU
CFLAGS+=-DGPU
COMMON+= -DGPU
CFLAGS+= -DGPU
LDFLAGS+= -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand
endif

Expand Down
204 changes: 0 additions & 204 deletions cfg/detection.cfg

This file was deleted.

9 changes: 5 additions & 4 deletions cfg/rescore.cfg → cfg/yolo.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[net]
batch=64
subdivisions=4
batch=1
subdivisions=1
height=448
width=448
channels=3
Expand Down Expand Up @@ -199,6 +199,7 @@ activation=logistic
[detection]
classes=20
coords=4
rescore=1
nuisance = 0
rescore=0
joint=1
objectness = 0
background=0
Binary file added data/dog.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/eagle.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/horses.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/person.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/captcha.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ void decode_captcha(char *cfgfile, char *weightfile)
float *predictions = network_predict(net, X);
image out = float_to_image(300, 57, 1, predictions);
show_image(out, "decoded");
#ifdef OPENCV
cvWaitKey(0);
#endif
free_image(im);
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/convolutional_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@ image get_convolutional_filter(convolutional_layer l, int i)
return float_to_image(w,h,c,l.filters+i*h*w*c);
}

void rgbgr_filters(convolutional_layer l)
{
int i;
for(i = 0; i < l.n; ++i){
image im = get_convolutional_filter(l, i);
if (im.c == 3) rgbgr_image(im);
}
}

image *get_filters(convolutional_layer l)
{
image *filters = calloc(l.n, sizeof(image));
Expand Down
8 changes: 4 additions & 4 deletions src/crop_layer_kernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,19 @@ __global__ void levels_image_kernel(float *image, float *rand, int batch, int w,

size_t offset = id * h * w * 3;
image += offset;
float r = image[x + w*(y + h*2)];
float r = image[x + w*(y + h*0)];
float g = image[x + w*(y + h*1)];
float b = image[x + w*(y + h*0)];
float b = image[x + w*(y + h*2)];
float3 rgb = make_float3(r,g,b);
if(train){
float3 hsv = rgb_to_hsv_kernel(rgb);
hsv.y *= saturation;
hsv.z *= exposure;
rgb = hsv_to_rgb_kernel(hsv);
}
image[x + w*(y + h*2)] = rgb.x*scale + translate;
image[x + w*(y + h*0)] = rgb.x*scale + translate;
image[x + w*(y + h*1)] = rgb.y*scale + translate;
image[x + w*(y + h*0)] = rgb.z*scale + translate;
image[x + w*(y + h*2)] = rgb.z*scale + translate;
}

__global__ void forward_crop_layer_kernel(float *input, float *rand, int size, int c, int h, int w, int crop_height, int crop_width, int train, int flip, float angle, float *output)
Expand Down
24 changes: 24 additions & 0 deletions src/darknet.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,40 @@ void partial(char *cfgfile, char *weightfile, char *outfile, int max)
save_weights(net, outfile);
}

#include "convolutional_layer.h"
void rgbgr_filters(convolutional_layer l);
void rgbgr_net(char *cfgfile, char *weightfile, char *outfile)
{
network net = parse_network_cfg(cfgfile);
if(weightfile){
load_weights(&net, weightfile);
}
int i;
for(i = 0; i < net.n; ++i){
layer l = net.layers[i];
if(l.type == CONVOLUTIONAL){
rgbgr_filters(l);
break;
}
}
save_weights(net, outfile);
}

void visualize(char *cfgfile, char *weightfile)
{
network net = parse_network_cfg(cfgfile);
if(weightfile){
load_weights(&net, weightfile);
}
visualize_network(net);
#ifdef OPENCV
cvWaitKey(0);
#endif
}

int main(int argc, char **argv)
{
//test_resize("data/cat.png");
//test_box();
//test_convolutional_layer();
if(argc < 2){
Expand Down Expand Up @@ -114,6 +136,8 @@ int main(int argc, char **argv)
run_captcha(argc, argv);
} else if (0 == strcmp(argv[1], "change")){
change_rate(argv[2], atof(argv[3]), (argc > 4) ? atof(argv[4]) : 0);
} else if (0 == strcmp(argv[1], "rgbgr")){
rgbgr_net(argv[2], argv[3], argv[4]);
} else if (0 == strcmp(argv[1], "partial")){
partial(argv[2], argv[3], argv[4], atoi(argv[5]));
} else if (0 == strcmp(argv[1], "visualize")){
Expand Down
2 changes: 1 addition & 1 deletion src/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ matrix load_image_paths_gray(char **paths, int n, int w, int h)
X.cols = 0;

for(i = 0; i < n; ++i){
image im = load_image(paths[i], w, h);
image im = load_image(paths[i], w, h, 1);
X.vals[i] = im.data;
X.cols = im.h*im.w*im.c;
}
Expand Down
Loading

0 comments on commit cbc9984

Please sign in to comment.