mirror of https://github.com/AlexeyAB/darknet.git
parent
c899cc19f4
commit
481b57a96a
49 changed files with 631 additions and 916 deletions
@ -1,6 +1,19 @@ |
||||
import os |
||||
import string |
||||
import pipes |
||||
|
||||
l = ["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", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"] |
||||
#l = ["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", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"] |
||||
|
||||
l = string.printable |
||||
|
||||
for word in l: |
||||
os.system("convert -fill black -background white -bordercolor white -border 4 -font futura-normal -pointsize 18 label:\"%s\" \"%s.png\""%(word, word)) |
||||
#os.system("convert -fill black -background white -bordercolor white -border 4 -font futura-normal -pointsize 18 label:\"%s\" \"%s.png\""%(word, word)) |
||||
if word == ' ': |
||||
os.system('convert -fill black -background white -bordercolor white -font futura-normal -pointsize 64 label:"\ " 32.png') |
||||
elif word == '\\': |
||||
os.system('convert -fill black -background white -bordercolor white -font futura-normal -pointsize 64 label:"\\\\\\\\" 92.png') |
||||
elif ord(word) in [9,10,11,12,13,14]: |
||||
pass |
||||
else: |
||||
os.system("convert -fill black -background white -bordercolor white -font futura-normal -pointsize 64 label:%s \"%d.png\""%(pipes.quote(word), ord(word))) |
||||
|
||||
|
@ -1,86 +0,0 @@ |
||||
#include "xnor_layer.h" |
||||
#include "binary_convolution.h" |
||||
#include "convolutional_layer.h" |
||||
|
||||
layer make_xnor_layer(int batch, int h, int w, int c, int n, int size, int stride, int pad, ACTIVATION activation, int batch_normalize) |
||||
{ |
||||
int i; |
||||
layer l = {0}; |
||||
l.type = XNOR; |
||||
|
||||
l.h = h; |
||||
l.w = w; |
||||
l.c = c; |
||||
l.n = n; |
||||
l.batch = batch; |
||||
l.stride = stride; |
||||
l.size = size; |
||||
l.pad = pad; |
||||
l.batch_normalize = batch_normalize; |
||||
|
||||
l.filters = calloc(c*n*size*size, sizeof(float)); |
||||
l.biases = calloc(n, sizeof(float)); |
||||
|
||||
int out_h = convolutional_out_height(l); |
||||
int out_w = convolutional_out_width(l); |
||||
l.out_h = out_h; |
||||
l.out_w = out_w; |
||||
l.out_c = n; |
||||
l.outputs = l.out_h * l.out_w * l.out_c; |
||||
l.inputs = l.w * l.h * l.c; |
||||
|
||||
l.output = calloc(l.batch*out_h * out_w * n, sizeof(float)); |
||||
|
||||
if(batch_normalize){ |
||||
l.scales = calloc(n, sizeof(float)); |
||||
for(i = 0; i < n; ++i){ |
||||
l.scales[i] = 1; |
||||
} |
||||
|
||||
l.mean = calloc(n, sizeof(float)); |
||||
l.variance = calloc(n, sizeof(float)); |
||||
|
||||
l.rolling_mean = calloc(n, sizeof(float)); |
||||
l.rolling_variance = calloc(n, sizeof(float)); |
||||
} |
||||
|
||||
l.activation = activation; |
||||
|
||||
fprintf(stderr, "XNOR Layer: %d x %d x %d image, %d filters -> %d x %d x %d image\n", h,w,c,n, out_h, out_w, n); |
||||
|
||||
return l; |
||||
} |
||||
|
||||
void forward_xnor_layer(const layer l, network_state state) |
||||
{ |
||||
int b = l.n; |
||||
int c = l.c; |
||||
int ix = l.w; |
||||
int iy = l.h; |
||||
int wx = l.size; |
||||
int wy = l.size; |
||||
int s = l.stride; |
||||
int pad = l.pad * (l.size/2); |
||||
|
||||
// MANDATORY: Make the binary layer
|
||||
ai2_bin_conv_layer al = ai2_make_bin_conv_layer(b, c, ix, iy, wx, wy, s, pad); |
||||
|
||||
// OPTIONAL: You need to set the real-valued input like:
|
||||
ai2_setFltInput_unpadded(&al, state.input); |
||||
// The above function will automatically binarize the input for the layer (channel wise).
|
||||
// If commented: using the default 0-valued input.
|
||||
|
||||
ai2_setFltWeights(&al, l.filters); |
||||
// The above function will automatically binarize the input for the layer (channel wise).
|
||||
// If commented: using the default 0-valued weights.
|
||||
|
||||
// MANDATORY: Call forward
|
||||
ai2_bin_forward(&al); |
||||
|
||||
// OPTIONAL: Inspect outputs
|
||||
float *output = ai2_getFltOutput(&al); // output is of size l.px * l.py where px and py are the padded outputs
|
||||
|
||||
memcpy(l.output, output, l.outputs*sizeof(float)); |
||||
// MANDATORY: Free layer
|
||||
ai2_free_bin_conv_layer(&al); |
||||
} |
@ -1,11 +0,0 @@ |
||||
#ifndef XNOR_LAYER_H |
||||
#define XNOR_LAYER_H |
||||
|
||||
#include "layer.h" |
||||
#include "network.h" |
||||
|
||||
layer make_xnor_layer(int batch, int h, int w, int c, int n, int size, int stride, int pad, ACTIVATION activation, int batch_normalization); |
||||
void forward_xnor_layer(const layer l, network_state state); |
||||
|
||||
#endif |
||||
|
Loading…
Reference in new issue