# Yolo 1. 先載入模型 2. 讀取圖片 3. 測試圖片 4. 排序 bounding box ```cpp= network *load_network_custom(char *cfg, char *weights, int clear, int batch); metadata get_metadata(char *file); int network_width(network *net); int network_height(network *net); image load_image_color(char *filename, int w, int h); image resize_image(image im, int w, int h); float *network_predict(network net, float *input); detection *get_network_boxes(network *net, int w, int h, float thresh, float hier, int *map, int relative, int *num, int letter); void do_nms_sort(detection *dets, int total, int classes, float thresh); void free_detections(detection *dets, int n); ``` ```python= thresh = 0.5 hier_thresh = 0.5 nms = 0.45 # 1. 先載入模型 net = load_network_custom(file.cfg, file.weights, 0, 1) meta = load_meta(file.data) im = load_image(image, 0, 0) sized = resize_image(im, network_width(net), network_height(net)) X = c_float() pX = pointer(X) pX = sized.data ''' C 寫法 float *X = sized.data; ''' network_predict(net, pX) num = c_int(0) pnum = pointer(num) letter_box = 0 dets = get_network_boxes(net, im.w, im.h, thresh, hier_thresh, None, 0, pnum, letter_box) num = pnum[0] # 多少 bounding box do_nms_sort(dets, num, meta.classes, nms) free_detections(dets, num) ```