-
Notifications
You must be signed in to change notification settings - Fork 2
/
yolo_net.go
41 lines (37 loc) · 1.03 KB
/
yolo_net.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package license_plate_recognition
import (
"github.com/LdDl/go-darknet"
)
const (
gpuIndex = 0
)
// YOLONetwork Aggregate two neural networks: one is for finding license plates, another is for OCR
type YOLONetwork struct {
LicensePlates *darknet.YOLONetwork
OCR *darknet.YOLONetwork
}
// NewYOLONetwork Return pointer to YOLONetwork
func NewYOLONetwork(platesCfg, platesWeights, ocrCfg, ocrWeights string, platesThreshold, ocrThreshold float32) (*YOLONetwork, error) {
plates := darknet.YOLONetwork{
GPUDeviceIndex: 0,
WeightsFile: platesWeights,
NetworkConfigurationFile: platesCfg,
Threshold: platesThreshold,
}
ocr := darknet.YOLONetwork{
GPUDeviceIndex: 0,
WeightsFile: ocrWeights,
NetworkConfigurationFile: ocrCfg,
Threshold: ocrThreshold,
}
if err := plates.Init(); err != nil {
return nil, err
}
if err := ocr.Init(); err != nil {
return nil, err
}
return &YOLONetwork{
LicensePlates: &plates,
OCR: &ocr,
}, nil
}