mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
Fixed darknet.py - uses batch=1 by default
This commit is contained in:
@ -160,6 +160,10 @@ load_net = lib.load_network
|
|||||||
load_net.argtypes = [c_char_p, c_char_p, c_int]
|
load_net.argtypes = [c_char_p, c_char_p, c_int]
|
||||||
load_net.restype = c_void_p
|
load_net.restype = c_void_p
|
||||||
|
|
||||||
|
load_net_custom = lib.load_network_custom
|
||||||
|
load_net_custom.argtypes = [c_char_p, c_char_p, c_int, c_int]
|
||||||
|
load_net_custom.restype = c_void_p
|
||||||
|
|
||||||
do_nms_obj = lib.do_nms_obj
|
do_nms_obj = lib.do_nms_obj
|
||||||
do_nms_obj.argtypes = [POINTER(DETECTION), c_int, c_int, c_float]
|
do_nms_obj.argtypes = [POINTER(DETECTION), c_int, c_int, c_float]
|
||||||
|
|
||||||
@ -325,7 +329,7 @@ def performDetect(imagePath="data/dog.jpg", thresh= 0.25, configPath = "./cfg/yo
|
|||||||
if not os.path.exists(metaPath):
|
if not os.path.exists(metaPath):
|
||||||
raise ValueError("Invalid data file path `"+os.path.abspath(metaPath)+"`")
|
raise ValueError("Invalid data file path `"+os.path.abspath(metaPath)+"`")
|
||||||
if netMain is None:
|
if netMain is None:
|
||||||
netMain = load_net(configPath.encode("ascii"), weightPath.encode("ascii"), 0)
|
netMain = load_net_custom(configPath.encode("ascii"), weightPath.encode("ascii"), 0, 1) # batch size = 1
|
||||||
if metaMain is None:
|
if metaMain is None:
|
||||||
metaMain = load_meta(metaPath.encode("ascii"))
|
metaMain = load_meta(metaPath.encode("ascii"))
|
||||||
if altNames is None:
|
if altNames is None:
|
||||||
|
@ -6,4 +6,12 @@ rem C:\Python27\Scripts\pip install scipy
|
|||||||
C:\Python27\python.exe darknet.py
|
C:\Python27\python.exe darknet.py
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
rem Python 3.6
|
||||||
|
rem C:\Users\Alex\AppData\Local\Programs\Python\Python36\Scripts\pip install numpy
|
||||||
|
rem C:\Users\Alex\AppData\Local\Programs\Python\Python36\Scripts\pip install scikit-image
|
||||||
|
rem C:\Users\Alex\AppData\Local\Programs\Python\Python36\Scripts\pip install scipy
|
||||||
|
|
||||||
|
rem C:\Users\Alex\AppData\Local\Programs\Python\Python36\python.exe darknet.py
|
||||||
|
|
||||||
pause
|
pause
|
@ -160,6 +160,10 @@ load_net = lib.load_network
|
|||||||
load_net.argtypes = [c_char_p, c_char_p, c_int]
|
load_net.argtypes = [c_char_p, c_char_p, c_int]
|
||||||
load_net.restype = c_void_p
|
load_net.restype = c_void_p
|
||||||
|
|
||||||
|
load_net_custom = lib.load_network_custom
|
||||||
|
load_net_custom.argtypes = [c_char_p, c_char_p, c_int, c_int]
|
||||||
|
load_net_custom.restype = c_void_p
|
||||||
|
|
||||||
do_nms_obj = lib.do_nms_obj
|
do_nms_obj = lib.do_nms_obj
|
||||||
do_nms_obj.argtypes = [POINTER(DETECTION), c_int, c_int, c_float]
|
do_nms_obj.argtypes = [POINTER(DETECTION), c_int, c_int, c_float]
|
||||||
|
|
||||||
@ -325,7 +329,7 @@ def performDetect(imagePath="data/dog.jpg", thresh= 0.25, configPath = "./cfg/yo
|
|||||||
if not os.path.exists(metaPath):
|
if not os.path.exists(metaPath):
|
||||||
raise ValueError("Invalid data file path `"+os.path.abspath(metaPath)+"`")
|
raise ValueError("Invalid data file path `"+os.path.abspath(metaPath)+"`")
|
||||||
if netMain is None:
|
if netMain is None:
|
||||||
netMain = load_net(configPath.encode("ascii"), weightPath.encode("ascii"), 0)
|
netMain = load_net_custom(configPath.encode("ascii"), weightPath.encode("ascii"), 0, 1) # batch size = 1
|
||||||
if metaMain is None:
|
if metaMain is None:
|
||||||
metaMain = load_meta(metaPath.encode("ascii"))
|
metaMain = load_meta(metaPath.encode("ascii"))
|
||||||
if altNames is None:
|
if altNames is None:
|
||||||
|
@ -137,7 +137,10 @@ box_label *read_boxes(char *filename, int *n)
|
|||||||
{
|
{
|
||||||
box_label *boxes = calloc(1, sizeof(box_label));
|
box_label *boxes = calloc(1, sizeof(box_label));
|
||||||
FILE *file = fopen(filename, "r");
|
FILE *file = fopen(filename, "r");
|
||||||
if(!file) file_error(filename);
|
if (!file) {
|
||||||
|
printf("Can't open label file. \n");
|
||||||
|
file_error(filename);
|
||||||
|
}
|
||||||
float x, y, h, w;
|
float x, y, h, w;
|
||||||
int id;
|
int id;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -30,11 +30,11 @@
|
|||||||
#include "yolo_layer.h"
|
#include "yolo_layer.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
network *load_network(char *cfg, char *weights, int clear)
|
network *load_network_custom(char *cfg, char *weights, int clear, int batch)
|
||||||
{
|
{
|
||||||
printf(" Try to load cfg: %s, weights: %s, clear = %d \n", cfg, weights, clear);
|
printf(" Try to load cfg: %s, weights: %s, clear = %d \n", cfg, weights, clear);
|
||||||
network *net = calloc(1, sizeof(network));
|
network *net = calloc(1, sizeof(network));
|
||||||
*net = parse_network_cfg(cfg);
|
*net = parse_network_cfg_custom(cfg, batch);
|
||||||
if (weights && weights[0] != 0) {
|
if (weights && weights[0] != 0) {
|
||||||
load_weights(net, weights);
|
load_weights(net, weights);
|
||||||
}
|
}
|
||||||
@ -42,6 +42,11 @@ network *load_network(char *cfg, char *weights, int clear)
|
|||||||
return net;
|
return net;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
network *load_network(char *cfg, char *weights, int clear)
|
||||||
|
{
|
||||||
|
return load_network_custom(cfg, weights, clear, 0);
|
||||||
|
}
|
||||||
|
|
||||||
int get_current_batch(network net)
|
int get_current_batch(network net)
|
||||||
{
|
{
|
||||||
int batch_num = (*net.seen)/(net.batch*net.subdivisions);
|
int batch_num = (*net.seen)/(net.batch*net.subdivisions);
|
||||||
|
@ -138,6 +138,7 @@ YOLODLL_API detection *get_network_boxes(network *net, int w, int h, float thres
|
|||||||
YOLODLL_API detection *make_network_boxes(network *net, float thresh, int *num);
|
YOLODLL_API detection *make_network_boxes(network *net, float thresh, int *num);
|
||||||
YOLODLL_API void free_detections(detection *dets, int n);
|
YOLODLL_API void free_detections(detection *dets, int n);
|
||||||
YOLODLL_API void reset_rnn(network *net);
|
YOLODLL_API void reset_rnn(network *net);
|
||||||
|
YOLODLL_API network *load_network_custom(char *cfg, char *weights, int clear, int batch);
|
||||||
YOLODLL_API network *load_network(char *cfg, char *weights, int clear);
|
YOLODLL_API network *load_network(char *cfg, char *weights, int clear);
|
||||||
YOLODLL_API float *network_predict_image(network *net, image im);
|
YOLODLL_API float *network_predict_image(network *net, image im);
|
||||||
YOLODLL_API void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, int ngpus, int clear, int dont_show);
|
YOLODLL_API void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, int ngpus, int clear, int dont_show);
|
||||||
|
Reference in New Issue
Block a user