Skip to content

Commit

Permalink
🐍 🐍 🐍 🐍
Browse files Browse the repository at this point in the history
  • Loading branch information
pjreddie committed Jun 8, 2017
1 parent 56d69e7 commit fc06959
Show file tree
Hide file tree
Showing 37 changed files with 457 additions and 289 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.out
*.png
*.jpg
*.pyc
old/
mnist/
data/
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ 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
LIB=libdarknet.so
EXEC=darknet
OBJDIR=./obj/

CC=gcc
NVCC=nvcc
NVCC=nvcc --compiler-options '-fPIC'
AR=ar
ARFLAGS=-rv
OPTS=-Ofast
LDFLAGS= -lm -pthread
COMMON= -Iinclude/ -Isrc/
CFLAGS=-Wall -Wfatal-errors
CFLAGS=-Wall -Wfatal-errors -fPIC

ifeq ($(DEBUG), 1)
OPTS=-O0 -g
Expand Down Expand Up @@ -69,7 +69,7 @@ $(EXEC): $(EXECOBJ) $(LIB)
$(CC) $(COMMON) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(LIB)

$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $^
$(CC) $(CFLAGS) -shared $^ -o $@ $(LDFLAGS)

$(OBJDIR)%.o: %.c $(DEPS)
$(CC) $(COMMON) $(CFLAGS) -c $< -o $@
Expand Down
26 changes: 12 additions & 14 deletions cfg/cifar.cfg
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
[net]
batch=128
subdivisions=1
height=32
width=32
height=28
width=28
channels=3
momentum=0.9
decay=0.0005
max_crop=32
min_crop=32

hue=.1
saturation=.75
exposure=.75

learning_rate=0.4
policy=poly
power=4
max_batches = 50000

[crop]
crop_width=28
crop_height=28
flip=1
angle=0
saturation = 1
exposure = 1
noadjust=1
max_batches = 5000
momentum=0.9
decay=0.0005


[convolutional]
batch_normalize=1
Expand Down
1 change: 0 additions & 1 deletion examples/classifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ void train_classifier(char *datacfg, char *cfgfile, char *weightfile, int *gpus,
cuda_set_device(gpus[i]);
#endif
nets[i] = load_network(cfgfile, weightfile, clear);
nets[i].learning_rate *= ngpus;
}
srand(time(0));
network net = nets[0];
Expand Down
2 changes: 1 addition & 1 deletion examples/coco.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void test_coco(char *cfgfile, char *weightfile, char *filename, float thresh)
if(weightfile){
load_weights(&net, weightfile);
}
detection_layer l = net.layers[net.n-1];
layer l = net.layers[net.n-1];
set_batch_network(&net, 1);
srand(2222222);
float nms = .4;
Expand Down
7 changes: 1 addition & 6 deletions examples/detector.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
#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].learning_rate *= ngpus;
nets[i] = load_network(cfgfile, weightfile, clear);
}
srand(time(0));
network net = nets[0];
Expand Down
10 changes: 5 additions & 5 deletions examples/lsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ void train_dcgan(char *cfg, char *weight, char *acfg, char *aweight, int clear,
printf("%s\n", base);
network gnet = load_network(cfg, weight, clear);
network anet = load_network(acfg, aweight, clear);
float orig_rate = anet.learning_rate;
//float orig_rate = anet.learning_rate;

int start = 0;
int i, j, k;
Expand Down Expand Up @@ -494,7 +494,7 @@ void train_dcgan(char *cfg, char *weight, char *acfg, char *aweight, int clear,
int y_size = gnet.truths*gnet.batch;
float *imerror = cuda_make_array(0, y_size);

int ay_size = anet.truths*anet.batch;
//int ay_size = anet.truths*anet.batch;

float aloss_avg = -1;

Expand Down Expand Up @@ -664,14 +664,14 @@ void train_colorizer(char *cfg, char *weight, char *acfg, char *aweight, int cle
clock_t time;

int x_size = net.inputs*net.batch;
int y_size = x_size;
//int y_size = x_size;
net.delta = 0;
net.train = 1;
float *pixs = calloc(x_size, sizeof(float));
float *graypixs = calloc(x_size, sizeof(float));
float *y = calloc(y_size, sizeof(float));
//float *y = calloc(y_size, sizeof(float));

int ay_size = anet.outputs*anet.batch;
//int ay_size = anet.outputs*anet.batch;
anet.delta = 0;
anet.train = 1;

Expand Down
4 changes: 3 additions & 1 deletion examples/nightmare.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "darknet.h"

#include <math.h>

// ./darknet nightmare cfg/extractor.recon.cfg ~/trained/yolo-coco.conv frame6.png -reconstruct -iters 500 -i 3 -lambda .1 -rate .01 -smooth 2

float abs_mean(float *x, int n)
Expand Down Expand Up @@ -128,11 +130,11 @@ void smooth(image recon, image update, float lambda, int num)
void reconstruct_picture(network net, float *features, image recon, image update, float rate, float momentum, float lambda, int smooth_size, int iters)
{
int iter = 0;
layer l = get_network_output_layer(net);
for (iter = 0; iter < iters; ++iter) {
image delta = make_image(recon.w, recon.h, recon.c);

#ifdef GPU
layer l = get_network_output_layer(net);
cuda_push_array(net.input_gpu, recon.data, recon.w*recon.h*recon.c);
//cuda_push_array(net.truth_gpu, features, net.truths);
net.delta_gpu = cuda_make_array(delta.data, delta.w*delta.h*delta.c);
Expand Down
2 changes: 2 additions & 0 deletions examples/rnn.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "darknet.h"

#include <math.h>

typedef struct {
float *x;
float *y;
Expand Down
10 changes: 9 additions & 1 deletion examples/segmenter.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ void train_segmenter(char *datacfg, char *cfgfile, char *weightfile, int *gpus,
load_weights(&nets[i], weightfile);
}
if(clear) *nets[i].seen = 0;
nets[i].learning_rate *= ngpus;
}
srand(time(0));
network net = nets[0];
Expand Down Expand Up @@ -76,6 +75,15 @@ void train_segmenter(char *datacfg, char *cfgfile, char *weightfile, int *gpus,
pthread_join(load_thread, 0);
train = buffer;
load_thread = load_data(args);
image tr = float_to_image(net.w, net.h, 81, train.y.vals[0]);
image im = float_to_image(net.w, net.h, net.c, train.X.vals[0]);
image mask = mask_to_rgb(tr);
show_image(im, "input");
show_image(mask, "truth");
#ifdef OPENCV
cvWaitKey(100);
#endif
free_image(mask);

printf("Loaded: %lf seconds\n", sec(clock()-time));
time=clock();
Expand Down
2 changes: 1 addition & 1 deletion examples/yolo.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void test_yolo(char *cfgfile, char *weightfile, char *filename, float thresh)
if(weightfile){
load_weights(&net, weightfile);
}
detection_layer l = net.layers[net.n-1];
layer l = net.layers[net.n-1];
set_batch_network(&net, 1);
srand(2222222);
clock_t time;
Expand Down
Loading

0 comments on commit fc06959

Please sign in to comment.