mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
Minor Python and C API improvement
This commit is contained in:
@ -125,7 +125,7 @@ lib.network_width.restype = c_int
|
|||||||
lib.network_height.argtypes = [c_void_p]
|
lib.network_height.argtypes = [c_void_p]
|
||||||
lib.network_height.restype = c_int
|
lib.network_height.restype = c_int
|
||||||
|
|
||||||
predict = lib.network_predict
|
predict = lib.network_predict_ptr
|
||||||
predict.argtypes = [c_void_p, POINTER(c_float)]
|
predict.argtypes = [c_void_p, POINTER(c_float)]
|
||||||
predict.restype = POINTER(c_float)
|
predict.restype = POINTER(c_float)
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ free_detections.argtypes = [POINTER(DETECTION), c_int]
|
|||||||
free_ptrs = lib.free_ptrs
|
free_ptrs = lib.free_ptrs
|
||||||
free_ptrs.argtypes = [POINTER(c_void_p), c_int]
|
free_ptrs.argtypes = [POINTER(c_void_p), c_int]
|
||||||
|
|
||||||
network_predict = lib.network_predict
|
network_predict = lib.network_predict_ptr
|
||||||
network_predict.argtypes = [c_void_p, POINTER(c_float)]
|
network_predict.argtypes = [c_void_p, POINTER(c_float)]
|
||||||
|
|
||||||
reset_rnn = lib.reset_rnn
|
reset_rnn = lib.reset_rnn
|
||||||
|
@ -60,7 +60,7 @@ lib.network_width.restype = c_int
|
|||||||
lib.network_height.argtypes = [c_void_p]
|
lib.network_height.argtypes = [c_void_p]
|
||||||
lib.network_height.restype = c_int
|
lib.network_height.restype = c_int
|
||||||
|
|
||||||
predict = lib.network_predict
|
predict = lib.network_predict_ptr
|
||||||
predict.argtypes = [c_void_p, POINTER(c_float)]
|
predict.argtypes = [c_void_p, POINTER(c_float)]
|
||||||
predict.restype = POINTER(c_float)
|
predict.restype = POINTER(c_float)
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ free_detections.argtypes = [POINTER(DETECTION), c_int]
|
|||||||
free_ptrs = lib.free_ptrs
|
free_ptrs = lib.free_ptrs
|
||||||
free_ptrs.argtypes = [POINTER(c_void_p), c_int]
|
free_ptrs.argtypes = [POINTER(c_void_p), c_int]
|
||||||
|
|
||||||
network_predict = lib.network_predict
|
network_predict = lib.network_predict_ptr
|
||||||
network_predict.argtypes = [c_void_p, POINTER(c_float)]
|
network_predict.argtypes = [c_void_p, POINTER(c_float)]
|
||||||
|
|
||||||
reset_rnn = lib.reset_rnn
|
reset_rnn = lib.reset_rnn
|
||||||
|
@ -151,7 +151,7 @@ free_detections.argtypes = [POINTER(DETECTION), c_int]
|
|||||||
free_ptrs = lib.free_ptrs
|
free_ptrs = lib.free_ptrs
|
||||||
free_ptrs.argtypes = [POINTER(c_void_p), c_int]
|
free_ptrs.argtypes = [POINTER(c_void_p), c_int]
|
||||||
|
|
||||||
network_predict = lib.network_predict
|
network_predict = lib.network_predict_ptr
|
||||||
network_predict.argtypes = [c_void_p, POINTER(c_float)]
|
network_predict.argtypes = [c_void_p, POINTER(c_float)]
|
||||||
|
|
||||||
reset_rnn = lib.reset_rnn
|
reset_rnn = lib.reset_rnn
|
||||||
|
@ -60,7 +60,7 @@ lib.network_width.restype = c_int
|
|||||||
lib.network_height.argtypes = [c_void_p]
|
lib.network_height.argtypes = [c_void_p]
|
||||||
lib.network_height.restype = c_int
|
lib.network_height.restype = c_int
|
||||||
|
|
||||||
predict = lib.network_predict
|
predict = lib.network_predict_ptr
|
||||||
predict.argtypes = [c_void_p, POINTER(c_float)]
|
predict.argtypes = [c_void_p, POINTER(c_float)]
|
||||||
predict.restype = POINTER(c_float)
|
predict.restype = POINTER(c_float)
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ free_detections.argtypes = [POINTER(DETECTION), c_int]
|
|||||||
free_ptrs = lib.free_ptrs
|
free_ptrs = lib.free_ptrs
|
||||||
free_ptrs.argtypes = [POINTER(c_void_p), c_int]
|
free_ptrs.argtypes = [POINTER(c_void_p), c_int]
|
||||||
|
|
||||||
network_predict = lib.network_predict
|
network_predict = lib.network_predict_ptr
|
||||||
network_predict.argtypes = [c_void_p, POINTER(c_float)]
|
network_predict.argtypes = [c_void_p, POINTER(c_float)]
|
||||||
|
|
||||||
reset_rnn = lib.reset_rnn
|
reset_rnn = lib.reset_rnn
|
||||||
|
@ -745,6 +745,7 @@ LIB_API void do_nms_obj(detection *dets, int total, int classes, float thresh);
|
|||||||
|
|
||||||
// network.h
|
// network.h
|
||||||
LIB_API float *network_predict(network net, float *input);
|
LIB_API float *network_predict(network net, float *input);
|
||||||
|
LIB_API float *network_predict_ptr(network *net, float *input);
|
||||||
LIB_API detection *get_network_boxes(network *net, int w, int h, float thresh, float hier, int *map, int relative, int *num, int letter);
|
LIB_API detection *get_network_boxes(network *net, int w, int h, float thresh, float hier, int *map, int relative, int *num, int letter);
|
||||||
LIB_API void free_detections(detection *dets, int n);
|
LIB_API void free_detections(detection *dets, int n);
|
||||||
LIB_API void fuse_conv_batchnorm(network net);
|
LIB_API void fuse_conv_batchnorm(network net);
|
||||||
@ -766,6 +767,7 @@ LIB_API void optimize_picture(network *net, image orig, int max_layer, float sca
|
|||||||
|
|
||||||
// image.h
|
// image.h
|
||||||
LIB_API image resize_image(image im, int w, int h);
|
LIB_API image resize_image(image im, int w, int h);
|
||||||
|
LIB_API void copy_image_from_bytes(image im, char *pdata);
|
||||||
LIB_API image letterbox_image(image im, int w, int h);
|
LIB_API image letterbox_image(image im, int w, int h);
|
||||||
LIB_API void rgbgr_image(image im);
|
LIB_API void rgbgr_image(image im);
|
||||||
LIB_API image make_image(int w, int h, int c);
|
LIB_API image make_image(int w, int h, int c);
|
||||||
|
@ -247,6 +247,9 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
|
|||||||
if (mean_average_precision > 0) {
|
if (mean_average_precision > 0) {
|
||||||
printf("\n Last accuracy mAP@0.5 = %2.2f %% ", mean_average_precision*100);
|
printf("\n Last accuracy mAP@0.5 = %2.2f %% ", mean_average_precision*100);
|
||||||
}
|
}
|
||||||
|
int calc_map_for_each = 4 * train_images_num / (net.batch * net.subdivisions); // calculate mAP for each 4 Epochs
|
||||||
|
if (calc_map) printf("\n (next mAP calculation at %d iterations) ", (iter_map + calc_map_for_each));
|
||||||
|
|
||||||
if (net.cudnn_half) {
|
if (net.cudnn_half) {
|
||||||
if (i < net.burn_in * 3) printf("\n Tensor Cores are disabled until the first %d iterations are reached.", 3 * net.burn_in);
|
if (i < net.burn_in * 3) printf("\n Tensor Cores are disabled until the first %d iterations are reached.", 3 * net.burn_in);
|
||||||
else printf("\n Tensor Cores are used.");
|
else printf("\n Tensor Cores are used.");
|
||||||
@ -254,8 +257,6 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
|
|||||||
printf("\n %d: %f, %f avg loss, %f rate, %lf seconds, %d images\n", get_current_batch(net), loss, avg_loss, get_current_rate(net), (what_time_is_it_now() - time), i*imgs);
|
printf("\n %d: %f, %f avg loss, %f rate, %lf seconds, %d images\n", get_current_batch(net), loss, avg_loss, get_current_rate(net), (what_time_is_it_now() - time), i*imgs);
|
||||||
|
|
||||||
int draw_precision = 0;
|
int draw_precision = 0;
|
||||||
int calc_map_for_each = 4 * train_images_num / (net.batch * net.subdivisions); // calculate mAP for each 4 Epochs
|
|
||||||
if (calc_map) printf(" Next mAP calculation at %d iterations \n", (iter_map + calc_map_for_each));
|
|
||||||
if (calc_map && (i >= (iter_map + calc_map_for_each) || i == net.max_batches) && i >= net.burn_in && i >= 1000) {
|
if (calc_map && (i >= (iter_map + calc_map_for_each) || i == net.max_batches) && i >= net.burn_in && i >= 1000) {
|
||||||
if (l.random) {
|
if (l.random) {
|
||||||
printf("Resizing to initial size: %d x %d \n", init_w, init_h);
|
printf("Resizing to initial size: %d x %d \n", init_w, init_h);
|
||||||
|
@ -33,7 +33,7 @@ image random_crop_image(image im, int w, int h);
|
|||||||
image random_augment_image(image im, float angle, float aspect, int low, int high, int size);
|
image random_augment_image(image im, float angle, float aspect, int low, int high, int size);
|
||||||
void random_distort_image(image im, float hue, float saturation, float exposure);
|
void random_distort_image(image im, float hue, float saturation, float exposure);
|
||||||
//LIB_API image resize_image(image im, int w, int h);
|
//LIB_API image resize_image(image im, int w, int h);
|
||||||
LIB_API void copy_image_from_bytes(image im, char *pdata);
|
//LIB_API void copy_image_from_bytes(image im, char *pdata);
|
||||||
void fill_image(image m, float s);
|
void fill_image(image m, float s);
|
||||||
void letterbox_image_into(image im, int w, int h, image boxed);
|
void letterbox_image_into(image im, int w, int h, image boxed);
|
||||||
//LIB_API image letterbox_image(image im, int w, int h);
|
//LIB_API image letterbox_image(image im, int w, int h);
|
||||||
|
@ -738,6 +738,7 @@ float *network_predict_image(network *net, image im)
|
|||||||
{
|
{
|
||||||
//image imr = letterbox_image(im, net->w, net->h);
|
//image imr = letterbox_image(im, net->w, net->h);
|
||||||
float *p;
|
float *p;
|
||||||
|
if(net->batch != 1) set_batch_network(net, 1);
|
||||||
if (im.w == net->w && im.h == net->h) {
|
if (im.w == net->w && im.h == net->h) {
|
||||||
// Input image is the same size as our net, predict on that image
|
// Input image is the same size as our net, predict on that image
|
||||||
p = network_predict(*net, im.data);
|
p = network_predict(*net, im.data);
|
||||||
|
@ -122,7 +122,7 @@ float train_network_datum(network net, float *x, float *y);
|
|||||||
|
|
||||||
matrix network_predict_data(network net, data test);
|
matrix network_predict_data(network net, data test);
|
||||||
//LIB_API float *network_predict(network net, float *input);
|
//LIB_API float *network_predict(network net, float *input);
|
||||||
LIB_API float *network_predict_ptr(network *net, float *input);
|
//LIB_API float *network_predict_ptr(network *net, float *input);
|
||||||
float network_accuracy(network net, data d);
|
float network_accuracy(network net, data d);
|
||||||
float *network_accuracies(network net, data d, int n);
|
float *network_accuracies(network net, data d, int n);
|
||||||
float network_accuracy_multi(network net, data d, int n);
|
float network_accuracy_multi(network net, data d, int n);
|
||||||
|
Reference in New Issue
Block a user