mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
I WISH I HAD SOME TESTS THOUGH
This commit is contained in:
parent
16686cec57
commit
56be49aa48
@ -7,11 +7,12 @@ import sys, os
|
|||||||
sys.path.append(os.path.join(os.getcwd(),'python/'))
|
sys.path.append(os.path.join(os.getcwd(),'python/'))
|
||||||
|
|
||||||
import darknet as dn
|
import darknet as dn
|
||||||
|
import pdb
|
||||||
|
|
||||||
dn.set_gpu(0)
|
dn.set_gpu(0)
|
||||||
net = dn.load_net("cfg/tiny-yolo.cfg", "tiny-yolo.weights", 0)
|
net = dn.load_net("cfg/yolo-thor.cfg", "/home/pjreddie/backup/yolo-thor_final.weights", 0)
|
||||||
meta = dn.load_meta("cfg/coco.data")
|
meta = dn.load_meta("cfg/thor.data")
|
||||||
r = dn.detect(net, meta, "data/dog.jpg")
|
r = dn.detect(net, meta, "data/bedroom.jpg")
|
||||||
print r
|
print r
|
||||||
|
|
||||||
# And then down here you could detect a lot more images like:
|
# And then down here you could detect a lot more images like:
|
||||||
|
@ -62,7 +62,7 @@ void optimize_picture(network *net, image orig, int max_layer, float scale, floa
|
|||||||
cuda_free(net->delta_gpu);
|
cuda_free(net->delta_gpu);
|
||||||
net->delta_gpu = 0;
|
net->delta_gpu = 0;
|
||||||
#else
|
#else
|
||||||
net->input = im.data;
|
copy_cpu(net->inputs, im.data, 1, net->input, 1);
|
||||||
net->delta = delta.data;
|
net->delta = delta.data;
|
||||||
forward_network(net);
|
forward_network(net);
|
||||||
copy_cpu(last.outputs, last.output, 1, last.delta, 1);
|
copy_cpu(last.outputs, last.output, 1, last.delta, 1);
|
||||||
|
@ -13,7 +13,9 @@ def sample(probs):
|
|||||||
return len(probs)-1
|
return len(probs)-1
|
||||||
|
|
||||||
def c_array(ctype, values):
|
def c_array(ctype, values):
|
||||||
return (ctype * len(values))(*values)
|
arr = (ctype*len(values))()
|
||||||
|
arr[:] = values
|
||||||
|
return arr
|
||||||
|
|
||||||
class BOX(Structure):
|
class BOX(Structure):
|
||||||
_fields_ = [("x", c_float),
|
_fields_ = [("x", c_float),
|
||||||
|
@ -236,7 +236,7 @@ void backward_convolutional_layer_gpu(convolutional_layer l, network net)
|
|||||||
float *b = net.workspace;
|
float *b = net.workspace;
|
||||||
float *c = l.weight_updates_gpu + j*l.nweights/l.groups;
|
float *c = l.weight_updates_gpu + j*l.nweights/l.groups;
|
||||||
|
|
||||||
float *im = net.input+(i*l.groups + j)*l.c/l.groups*l.h*l.w;
|
float *im = net.input_gpu+(i*l.groups + j)*l.c/l.groups*l.h*l.w;
|
||||||
|
|
||||||
im2col_gpu(im, l.c/l.groups, l.h, l.w,
|
im2col_gpu(im, l.c/l.groups, l.h, l.w,
|
||||||
l.size, l.stride, l.pad, b);
|
l.size, l.stride, l.pad, b);
|
||||||
|
@ -150,24 +150,24 @@ void cudnn_convolutional_setup(layer *l)
|
|||||||
l->weightDesc,
|
l->weightDesc,
|
||||||
l->convDesc,
|
l->convDesc,
|
||||||
l->dstTensorDesc,
|
l->dstTensorDesc,
|
||||||
CUDNN_CONVOLUTION_FWD_PREFER_FASTEST,
|
CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT,
|
||||||
0,
|
4000000000,
|
||||||
&l->fw_algo);
|
&l->fw_algo);
|
||||||
cudnnGetConvolutionBackwardDataAlgorithm(cudnn_handle(),
|
cudnnGetConvolutionBackwardDataAlgorithm(cudnn_handle(),
|
||||||
l->weightDesc,
|
l->weightDesc,
|
||||||
l->ddstTensorDesc,
|
l->ddstTensorDesc,
|
||||||
l->convDesc,
|
l->convDesc,
|
||||||
l->dsrcTensorDesc,
|
l->dsrcTensorDesc,
|
||||||
CUDNN_CONVOLUTION_BWD_DATA_PREFER_FASTEST,
|
CUDNN_CONVOLUTION_BWD_DATA_SPECIFY_WORKSPACE_LIMIT,
|
||||||
0,
|
4000000000,
|
||||||
&l->bd_algo);
|
&l->bd_algo);
|
||||||
cudnnGetConvolutionBackwardFilterAlgorithm(cudnn_handle(),
|
cudnnGetConvolutionBackwardFilterAlgorithm(cudnn_handle(),
|
||||||
l->srcTensorDesc,
|
l->srcTensorDesc,
|
||||||
l->ddstTensorDesc,
|
l->ddstTensorDesc,
|
||||||
l->convDesc,
|
l->convDesc,
|
||||||
l->dweightDesc,
|
l->dweightDesc,
|
||||||
CUDNN_CONVOLUTION_BWD_FILTER_PREFER_FASTEST,
|
CUDNN_CONVOLUTION_BWD_FILTER_SPECIFY_WORKSPACE_LIMIT,
|
||||||
0,
|
4000000000,
|
||||||
&l->bf_algo);
|
&l->bf_algo);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -389,6 +389,7 @@ int resize_network(network *net, int w, int h)
|
|||||||
error("Cannot resize this type of layer");
|
error("Cannot resize this type of layer");
|
||||||
}
|
}
|
||||||
if(l.workspace_size > workspace_size) workspace_size = l.workspace_size;
|
if(l.workspace_size > workspace_size) workspace_size = l.workspace_size;
|
||||||
|
if(l.workspace_size > 2000000000) assert(0);
|
||||||
inputs = l.outputs;
|
inputs = l.outputs;
|
||||||
net->layers[i] = l;
|
net->layers[i] = l;
|
||||||
w = l.out_w;
|
w = l.out_w;
|
||||||
|
Loading…
Reference in New Issue
Block a user