upd readme

This commit is contained in:
Dimitrii
2020-02-21 15:47:21 +03:00
parent e486364a2b
commit feb1a0353d
16 changed files with 88 additions and 185 deletions

View File

@@ -3,17 +3,19 @@
[![GoDoc](https://godoc.org/github.com/LdDl/go-darknet?status.svg)](https://godoc.org/github.com/LdDl/go-darknet) [![GoDoc](https://godoc.org/github.com/LdDl/go-darknet?status.svg)](https://godoc.org/github.com/LdDl/go-darknet)
go-darknet is a Go package, which uses Cgo to enable Go applications to use go-darknet is a Go package, which uses Cgo to enable Go applications to use YOLO in [Darknet].
YOLO in [Darknet].
## License ## Table of Contents
go-darknet follows [Darknet]'s [license]. - [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Documentation](#documentation)
- [License](#license)
## Requirements ## Requirements
For proper codebase please use fork of [darknet](https://github.com/AlexeyAB/darknet) For proper codebase please use fork of [darknet](https://github.com/AlexeyAB/darknet). Latest commit I've tested [here](https://github.com/AlexeyAB/darknet/commit/64fb042c63637038671ae9d53c06165599b28912)
There are instructions for defining GPU/CPU + function for loading image from memory.
In order to use go-darknet, `libdarknet.so` should be available in one of In order to use go-darknet, `libdarknet.so` should be available in one of
the following locations: the following locations:
@@ -26,53 +28,82 @@ Also, [darknet.h] should be available in one of the following locations:
* /usr/include * /usr/include
* /usr/local/include * /usr/local/include
## Install To achieve it, after Darknet compilation (via make) execute following command:
```shell
sudo cp libdarknet.so /usr/lib/libdarknet.so && sudo cp include/darknet.h /usr/local/include/darknet.h
```
## Installation
```shell ```shell
go get github.com/LdDl/go-darknet go get github.com/LdDl/go-darknet
``` ```
The package name is `darknet`. ## Usage
## Use Example Go program is provided in the [example] directory. Please refer to the code on how to use this Go package.
Example Go code/program is provided in the [example] directory. Please Building and running program:
refer to the code on how to use this Go package.
Building and running the example program is easy:
Navigate to [example] folder
```shell ```shell
cd $GOPATH/github.com/LdDl/go-darknet/example cd $GOPATH/github.com/LdDl/go-darknet/example
#download dataset (coco.names, coco.data, weights and configuration file) ```
Download dataset (sample of image, coco.names, yolov3.cfg, yolov3.weights).
```shell
./download_data.sh ./download_data.sh
#build program ```
go build main.go Note: you don't need *coco.data* file anymore, because script below does insert *coco.names* into 'names' filed in *yolov3.cfg* file (so AlexeyAB's fork can deal with it properly)
#run it So last rows in yolov3.cfg file will look like:
./main -configFile yolov3.cfg --dataConfigFile coco.data -imageFile sample.jpg -weightsFile yolov3.weights ```bash
......
[yolo]
mask = 0,1,2
anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326
classes=80
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1
names = coco.names # this is path to coco.names file
```
Build and run program
```
go build main.go && ./main --configFile=yolov3.cfg --weightsFile=yolov3.weights --imageFile=sample.jpg
``` ```
Output should be something like this: Output should be something like this:
```shell ```shell
truck (7): 95.6232% | start point: (78,69) | end point: (222, 291) truck (7): 49.5197% | start point: (0,136) | end point: (85, 311)
truck (7): 81.5451% | start point: (0,114) | end point: (90, 329) car (2): 36.3747% | start point: (95,152) | end point: (186, 283)
car (2): 99.8129% | start point: (269,192) | end point: (421, 323) truck (7): 48.4384% | start point: (95,152) | end point: (186, 283)
car (2): 99.6615% | start point: (567,188) | end point: (743, 329) truck (7): 45.6590% | start point: (694,178) | end point: (798, 310)
car (2): 99.5795% | start point: (425,196) | end point: (544, 309) car (2): 76.8379% | start point: (1,145) | end point: (84, 324)
car (2): 96.5765% | start point: (678,185) | end point: (797, 320) truck (7): 25.5731% | start point: (107,89) | end point: (215, 263)
car (2): 91.5156% | start point: (391,209) | end point: (441, 291) car (2): 99.8783% | start point: (511,185) | end point: (748, 328)
car (2): 88.1737% | start point: (507,193) | end point: (660, 324) car (2): 99.8194% | start point: (261,189) | end point: (427, 322)
car (2): 83.6209% | start point: (71,199) | end point: (102, 281) car (2): 99.6408% | start point: (426,197) | end point: (539, 311)
bicycle (1): 59.4000% | start point: (183,276) | end point: (257, 407) car (2): 74.5610% | start point: (692,186) | end point: (796, 316)
person (0): 96.3393% | start point: (142,119) | end point: (285, 356) car (2): 72.8053% | start point: (388,206) | end point: (437, 276)
bicycle (1): 72.2932% | start point: (178,270) | end point: (268, 406)
person (0): 97.3026% | start point: (143,135) | end point: (268, 343)
``` ```
## Documentation ## Documentation
See go-darknet's API documentation at [GoDoc]. See go-darknet's API documentation at [GoDoc].
## License
go-darknet follows [Darknet]'s [license].
[Darknet]: https://github.com/pjreddie/darknet [Darknet]: https://github.com/pjreddie/darknet
[license]: https://github.com/pjreddie/darknet/blob/master/LICENSE [license]: https://github.com/pjreddie/darknet/blob/master/LICENSE
[darknet.h]: https://github.com/pjreddie/darknet/blob/master/include/darknet.h [darknet.h]: https://github.com/AlexeyAB/darknet/blob/master/include/darknet.h
[include/darknet.h]: https://github.com/pjreddie/darknet/blob/master/include/darknet.h [include/darknet.h]: https://github.com/AlexeyAB/darknet/blob/master/include/darknet.h
[Makefile]: https://github.com/alexeyab/darknet/blob/master/Makefile [Makefile]: https://github.com/alexeyab/darknet/blob/master/Makefile
[example]: /example [example]: /example
[GoDoc]: https://godoc.org/github.com/LdDl/go-darknet [GoDoc]: https://godoc.org/github.com/LdDl/go-darknet

View File

@@ -8,8 +8,7 @@ func makeClassNames(names **C.char, classes int) []string {
out := make([]string, classes) out := make([]string, classes)
for i := 0; i < classes; i++ { for i := 0; i < classes; i++ {
n := C.get_class_name(names, C.int(i), C.int(classes)) n := C.get_class_name(names, C.int(i), C.int(classes))
s := C.GoString(n) out[i] = C.GoString(n)
out[i] = s
} }
return out return out
} }

View File

@@ -1,5 +1,5 @@
package darknet package darknet
// #cgo CFLAGS: -I/usr/local/include -I/usr/local/cuda/include // #cgo CFLAGS: -I/usr/local/include -I/usr/local/cuda/include
// #cgo LDFLAGS: -L./lib -ldarknet -lm // #cgo LDFLAGS: -L/usr/lib -ldarknet -lm
import "C" import "C"

View File

@@ -1,5 +0,0 @@
person
car
motorcycle
bus
truck

View File

@@ -2,7 +2,6 @@
#include "detection.h" #include "detection.h"
detection *get_detection(detection *dets, int index, int dets_len) { detection *get_detection(detection *dets, int index, int dets_len) {
if (index >= dets_len) { if (index >= dets_len) {
return NULL; return NULL;

View File

@@ -2,6 +2,5 @@
#include <darknet.h> #include <darknet.h>
extern detection *get_detection(detection *dets, int index, int dets_len); extern detection *get_detection(detection *dets, int index, int dets_len);
extern float get_detection_probability(detection *det, int index, int prob_len); extern float get_detection_probability(detection *det, int index, int prob_len);

View File

@@ -1,6 +1,5 @@
wget --output-document=sample.jpg https://cdn-images-1.medium.com/max/800/1*EYFejGUjvjPcc4PZTwoufw.jpeg wget --output-document=sample.jpg https://cdn-images-1.medium.com/max/800/1*EYFejGUjvjPcc4PZTwoufw.jpeg
wget --output-document=coco.names https://raw.githubusercontent.com/pjreddie/darknet/master/data/coco.names wget --output-document=coco.names https://raw.githubusercontent.com/AlexeyAB/darknet/master/data/coco.names
wget --output-document=coco.data https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/coco.data wget --output-document=yolov3.cfg https://raw.githubusercontent.com/AlexeyAB/darknet/master/cfg/yolov3.cfg
sed -i 's#data/coco.names#coco.names#g' coco.data sed -i -e "\$anames = coco.names" yolov3.cfg
wget --output-document=yolov3.cfg https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov3.cfg
wget --output-document=yolov3.weights https://pjreddie.com/media/files/yolov3.weights wget --output-document=yolov3.weights https://pjreddie.com/media/files/yolov3.weights

View File

@@ -12,8 +12,6 @@ import (
darknet "github.com/LdDl/go-darknet" darknet "github.com/LdDl/go-darknet"
) )
var dataConfigFile = flag.String("dataConfigFile", "",
"Path to data configuration file. Example: cfg/coco.data")
var configFile = flag.String("configFile", "", var configFile = flag.String("configFile", "",
"Path to network layer configuration file. Example: cfg/yolov3.cfg") "Path to network layer configuration file. Example: cfg/yolov3.cfg")
var weightsFile = flag.String("weightsFile", "", var weightsFile = flag.String("weightsFile", "",
@@ -28,7 +26,7 @@ func printError(err error) {
func main() { func main() {
flag.Parse() flag.Parse()
if *dataConfigFile == "" || *configFile == "" || *weightsFile == "" || if *configFile == "" || *weightsFile == "" ||
*imageFile == "" { *imageFile == "" {
flag.Usage() flag.Usage()
@@ -37,7 +35,6 @@ func main() {
n := darknet.YOLONetwork{ n := darknet.YOLONetwork{
GPUDeviceIndex: 0, GPUDeviceIndex: 0,
DataConfigurationFile: *dataConfigFile,
NetworkConfigurationFile: *configFile, NetworkConfigurationFile: *configFile,
WeightsFile: *weightsFile, WeightsFile: *weightsFile,
Threshold: .25, Threshold: .25,
@@ -58,18 +55,6 @@ func main() {
panic(err.Error()) panic(err.Error())
} }
// bytes <<<<<<<<<<<<<
// imgBytes, err := imageToBytes(src)
// if err != nil {
// panic(err.Error())
// }
// imgDarknet, err := darknet.ImageFromMemory(imgBytes, 4032, 3024)
// if err != nil {
// panic(err.Error())
// }
// defer imgDarknet.Close()
// bytes >>>>>>>>>>>>>
imgDarknet, err := darknet.Image2Float32(src) imgDarknet, err := darknet.Image2Float32(src)
if err != nil { if err != nil {
panic(err.Error()) panic(err.Error())

View File

@@ -1,18 +0,0 @@
[
{
"frame_id":1,
"filename":"/home/dimitrii/Downloads/mega.jpg",
"objects": [
{"class_id":3, "name":"bus", "relative_coordinates":{"center_x":0.475497, "center_y":0.317034, "width":0.175112, "height":0.104746}, "confidence":0.686032},
{"class_id":3, "name":"bus", "relative_coordinates":{"center_x":0.278355, "center_y":0.302800, "width":0.087061, "height":0.052067}, "confidence":0.562420},
{"class_id":1, "name":"car", "relative_coordinates":{"center_x":0.799558, "center_y":0.643484, "width":0.388328, "height":0.539759}, "confidence":0.942335},
{"class_id":1, "name":"car", "relative_coordinates":{"center_x":0.365836, "center_y":0.431383, "width":0.267126, "height":0.156932}, "confidence":0.776083},
{"class_id":1, "name":"car", "relative_coordinates":{"center_x":0.513763, "center_y":0.475799, "width":0.301966, "height":0.240549}, "confidence":0.684380},
{"class_id":1, "name":"car", "relative_coordinates":{"center_x":0.717148, "center_y":0.516788, "width":0.456320, "height":0.313704}, "confidence":0.584288},
{"class_id":1, "name":"car", "relative_coordinates":{"center_x":0.217955, "center_y":0.379872, "width":0.212185, "height":0.101100}, "confidence":0.468769},
{"class_id":1, "name":"car", "relative_coordinates":{"center_x":0.126970, "center_y":0.337752, "width":0.035609, "height":0.022990}, "confidence":0.452899},
{"class_id":0, "name":"person", "relative_coordinates":{"center_x":0.051506, "center_y":0.369395, "width":0.056224, "height":0.175025}, "confidence":0.978385},
{"class_id":0, "name":"person", "relative_coordinates":{"center_x":0.097309, "center_y":0.370574, "width":0.048715, "height":0.142128}, "confidence":0.801452}
]
}
]

25
image.c
View File

@@ -11,28 +11,3 @@ void set_data_f32_val(float* data, int index, float value) {
data[index] = value; data[index] = value;
} }
image resize_image_golang(image im, int w, int h) {
return resize_image(im, w, h);
}
image make_empty_image(int w, int h, int c)
{
image out;
out.data = 0;
out.h = h;
out.w = w;
out.c = c;
return out;
}
image float_to_image(int w, int h, int c, float *data)
{
image out = make_empty_image(w,h,c);
fill_image_f32(&out, w, h, c, data);
// for (i = 0; i < w*h*c; i++) {
// out.data[i] = data[i];
// }
return out;
}

View File

@@ -23,24 +23,20 @@ func (img *DarknetImage) Close() error {
return nil return nil
} }
func float_p(arr []float32) *C.float {
return (*C.float)(unsafe.Pointer(&arr[0]))
}
// https://stackoverflow.com/questions/33186783/get-a-pixel-array-from-from-golang-image-image/59747737#59747737 // https://stackoverflow.com/questions/33186783/get-a-pixel-array-from-from-golang-image-image/59747737#59747737
func image_2_array_pix(src image.Image) []float32 { func imgTofloat32(src image.Image) []float32 {
bounds := src.Bounds() bounds := src.Bounds()
width, height := bounds.Max.X, bounds.Max.Y width, height := bounds.Max.X, bounds.Max.Y
src_rgba := image.NewRGBA(src.Bounds()) srcRGBA := image.NewRGBA(src.Bounds())
draw.Copy(src_rgba, image.Point{}, src, src.Bounds(), draw.Src, nil) draw.Copy(srcRGBA, image.Point{}, src, src.Bounds(), draw.Src, nil)
ans := []float32{} ans := []float32{}
red := []float32{} red := []float32{}
green := []float32{} green := []float32{}
blue := []float32{} blue := []float32{}
for y := 0; y < height; y++ { for y := 0; y < height; y++ {
for x := 0; x < width; x++ { for x := 0; x < width; x++ {
idx_s := (y*width + x) * 4 idxSource := (y*width + x) * 4
pix := src_rgba.Pix[idx_s : idx_s+4] pix := srcRGBA.Pix[idxSource : idxSource+4]
rpix, gpix, bpix := float32(pix[0])/257.0, float32(pix[1])/257.0, float32(pix[2])/257.0 rpix, gpix, bpix := float32(pix[0])/257.0, float32(pix[1])/257.0, float32(pix[2])/257.0
red = append(red, rpix) red = append(red, rpix)
green = append(green, gpix) green = append(green, gpix)
@@ -55,7 +51,7 @@ func image_2_array_pix(src image.Image) []float32 {
// Image2Float32 Returns []float32 representation of image.Image // Image2Float32 Returns []float32 representation of image.Image
func Image2Float32(img image.Image) (*DarknetImage, error) { func Image2Float32(img image.Image) (*DarknetImage, error) {
ans := image_2_array_pix(img) ans := imgTofloat32(img)
width := img.Bounds().Dx() width := img.Bounds().Dx()
height := img.Bounds().Dy() height := img.Bounds().Dy()
imgDarknet := &DarknetImage{ imgDarknet := &DarknetImage{
@@ -63,10 +59,6 @@ func Image2Float32(img image.Image) (*DarknetImage, error) {
Height: height, Height: height,
image: C.make_image(C.int(width), C.int(height), 3), image: C.make_image(C.int(width), C.int(height), 3),
} }
// for i := range ans { C.fill_image_f32(&imgDarknet.image, C.int(width), C.int(height), 3, (*C.float)(unsafe.Pointer(&ans[0])))
// C.set_data_f32_val(imgDarknet.image.data, C.int(i), C.float(ans[i]))
// }
C.fill_image_f32(&imgDarknet.image, C.int(width), C.int(height), 3, float_p(ans))
// imgDarknet.image = C.load_image_color(C.CString("/home/dimitrii/Downloads/mega.jpg"), 4032, 3024)
return imgDarknet, nil return imgDarknet, nil
} }

View File

@@ -3,7 +3,4 @@
#include <darknet.h> #include <darknet.h>
extern void fill_image_f32(image *im, int w, int h, int c, float* data); extern void fill_image_f32(image *im, int w, int h, int c, float* data);
extern void set_data_f32_val(float* data, int index, float value); extern void set_data_f32_val(float* data, int index, float value);
extern image resize_image_golang(image im, int w, int h);
extern image make_empty_image(int w, int h, int c);
extern image float_to_image(int w, int h, int c, float *data);

View File

@@ -6,52 +6,23 @@
#include "detection.h" #include "detection.h"
struct network_box_result perform_network_detect(network *n, image img, int classes, float thresh, float hier_thresh, float nms, int letter_box) { struct network_box_result perform_network_detect(network *n, image *img, int classes, float thresh, float hier_thresh, float nms, int letter_box) {
image sized; image sized;
int ww = img.w;
int hh = img.h;
int cc = img.c;
if (letter_box) { if (letter_box) {
printf("using letter %d %d %d %d %d %d\n", letter_box, n->w, n->h, img.w, img.h, img.c); sized = letterbox_image(*img, n->w, n->h);
sized = letterbox_image(img, n->w, n->h);
} else { } else {
printf("not using letter: %d %d %d %d %d %d\n", letter_box, n->w, n->h, img.w, img.h, img.c); sized = resize_image(*img, n->w, n->h);
sized = resize_image(img, n->w, n->h);
} }
// printf("\n>>>>>>>>>>>>>>Fourth Print (Golang)\n");
// for (int i = 0; i< 50; i++) {
// printf("%f\n", sized.data[i]);
// }
// printf("\n<<<<<<<<<<<<<<Done\n");
// sized.data = float*{0.815686, 0.592875, 0.645386, 0.731689, 0.659976};
// newImg := resize_image_golang(imgDarknet.image, 416, 416)
struct network_box_result result = { NULL }; struct network_box_result result = { NULL };
float *X = sized.data; float *X = sized.data;
float *outnwt = network_predict_ptr(n, X); network_predict_ptr(n, X);
// printf("\n>>>>>>>>>>>>>>Golang out\n");
// for (int i = 0; i< 100; i++) {
// printf("%f ", outnwt[i]);
// }
// printf("\n<<<<<<<<<<<<<<Done\n");
int nboxes = 0; int nboxes = 0;
detection *dets = get_network_boxes(n, img.w, img.h, thresh, hier_thresh, 0, 1, &nboxes, letter_box); detection *dets = get_network_boxes(n, img->w, img->h, thresh, hier_thresh, 0, 1, &nboxes, letter_box);
printf("Clang number of detections: %d %d %d %f %f %d\n", nboxes, img.w, img.h, thresh, hier_thresh, letter_box); result.detections = get_network_boxes(n, img->w, img->h, thresh, hier_thresh, 0, 1, &result.detections_len, letter_box);
result.detections = get_network_boxes(n, img.w, img.h, thresh, hier_thresh, 0, 1, &result.detections_len, letter_box);
printf("Golang number of detections: %d\n", result.detections_len);
// printf("Clang number of detections: %d\n", result.detections_len);
if (nms) { if (nms) {
do_nms_sort(result.detections, result.detections_len, classes, nms); do_nms_sort(result.detections, result.detections_len, classes, nms);
} }
free_image(sized); free_image(sized);
return result; return result;
} }

View File

@@ -15,7 +15,6 @@ import (
// YOLONetwork represents a neural network using YOLO. // YOLONetwork represents a neural network using YOLO.
type YOLONetwork struct { type YOLONetwork struct {
GPUDeviceIndex int GPUDeviceIndex int
DataConfigurationFile string
NetworkConfigurationFile string NetworkConfigurationFile string
WeightsFile string WeightsFile string
Threshold float32 Threshold float32
@@ -29,47 +28,28 @@ type YOLONetwork struct {
} }
var ( var (
errNetworkNotInit = errors.New("network not initialised") errNetworkNotInit = errors.New("Network not initialised")
errUnableToInitNetwork = errors.New("unable to initialise") errUnableToInitNetwork = errors.New("Unable to initialise")
) )
// Init the network. // Init the network.
func (n *YOLONetwork) Init() error { func (n *YOLONetwork) Init() error {
nCfg := C.CString(n.NetworkConfigurationFile) nCfg := C.CString(n.NetworkConfigurationFile)
defer C.free(unsafe.Pointer(nCfg)) defer C.free(unsafe.Pointer(nCfg))
wFile := C.CString(n.WeightsFile) wFile := C.CString(n.WeightsFile)
defer C.free(unsafe.Pointer(wFile)) defer C.free(unsafe.Pointer(wFile))
// GPU device ID must be set before `load_network()` is invoked.
// data := C.CString(n.DataConfigurationFile)
// defer C.free(unsafe.Pointer(data))
// inptim := C.CString("/home/dimitrii/Downloads/mega.jpg")
// defer C.free(unsafe.Pointer(inptim))
// outputim := C.CString("/home/dimitrii/work/src/github.com/LdDl/go-darknet/example/out-sample.png")
// defer C.free(unsafe.Pointer(outputim))
// C.test_detector(data, nCfg, wFile, inptim, 0.4, 0.5, 1, 1, 0, outputim, 0, 0)
// // GPU device ID must be set before `load_network()` is invoked.
C.cuda_set_device(C.int(n.GPUDeviceIndex)) C.cuda_set_device(C.int(n.GPUDeviceIndex))
n.cNet = C.load_network(nCfg, wFile, 0) n.cNet = C.load_network(nCfg, wFile, 0)
if n.cNet == nil { if n.cNet == nil {
return errUnableToInitNetwork return errUnableToInitNetwork
} }
// C.set_batch_network(n.cNet, 1)
C.srand(2222222) C.srand(2222222)
n.hierarchalThreshold = 0.5 n.hierarchalThreshold = 0.5
n.nms = 0.45 n.nms = 0.45
metadata := C.get_metadata(nCfg) metadata := C.get_metadata(nCfg)
n.Classes = int(metadata.classes) n.Classes = int(metadata.classes)
n.ClassNames = makeClassNames(metadata.names, n.Classes) n.ClassNames = makeClassNames(metadata.names, n.Classes)
return nil return nil
} }
@@ -78,7 +58,6 @@ func (n *YOLONetwork) Close() error {
if n.cNet == nil { if n.cNet == nil {
return errNetworkNotInit return errNetworkNotInit
} }
C.free_network(*n.cNet) C.free_network(*n.cNet)
n.cNet = nil n.cNet = nil
return nil return nil
@@ -90,7 +69,7 @@ func (n *YOLONetwork) Detect(img *DarknetImage) (*DetectionResult, error) {
return nil, errNetworkNotInit return nil, errNetworkNotInit
} }
startTime := time.Now() startTime := time.Now()
result := C.perform_network_detect(n.cNet, img.image, C.int(n.Classes), C.float(n.Threshold), C.float(n.hierarchalThreshold), C.float(n.nms), C.int(0)) result := C.perform_network_detect(n.cNet, &img.image, C.int(n.Classes), C.float(n.Threshold), C.float(n.hierarchalThreshold), C.float(n.nms), C.int(0))
endTime := time.Now() endTime := time.Now()
defer C.free_detections(result.detections, result.detections_len) defer C.free_detections(result.detections, result.detections_len)
ds := makeDetections(img, result.detections, int(result.detections_len), n.Threshold, n.Classes, n.ClassNames) ds := makeDetections(img, result.detections, int(result.detections_len), n.Threshold, n.Classes, n.ClassNames)

View File

@@ -8,4 +8,4 @@ struct network_box_result {
}; };
extern int get_network_layer_classes(network *n, int index); extern int get_network_layer_classes(network *n, int index);
extern struct network_box_result perform_network_detect(network *n, image img, int classes, float thresh, float hier_thresh, float nms, int letter_box); extern struct network_box_result perform_network_detect(network *n, image *img, int classes, float thresh, float hier_thresh, float nms, int letter_box);