|
@@ -100,8 +100,17 @@ func AnalysisPhotoYOLO3(filename string) ([]*ImageClass, error) {
|
|
return results, errors.New("Source file not found")
|
|
return results, errors.New("Source file not found")
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //Check if there is yolov3.weight. If not, use yolo3_tiny.weight
|
|
|
|
+ pretrainWeight := "yolov3.weights"
|
|
|
|
+ networkConf := "cfg/yolov3.cfg"
|
|
|
|
+ if !filesystem.FileExists(filepath.Join(filepath.Dir(darknetBinary), "yolov3.weight")) {
|
|
|
|
+ //yolo3 weight not exists. Switch to yolov3_tiny (default, recommended)
|
|
|
|
+ pretrainWeight = "yolov3-tiny.weights"
|
|
|
|
+ networkConf = "cfg/yolov3-tiny.cfg"
|
|
|
|
+ }
|
|
|
|
+
|
|
//Analysis the image
|
|
//Analysis the image
|
|
- cmd := exec.Command(darknetBinary, "detect", "cfg/yolov3.cfg", "yolov3.weights", imageSourceAbs, "-out")
|
|
|
|
|
|
+ cmd := exec.Command(darknetBinary, "detect", networkConf, pretrainWeight, imageSourceAbs, "-out")
|
|
cmd.Dir = filepath.Dir(darknetBinary)
|
|
cmd.Dir = filepath.Dir(darknetBinary)
|
|
out, err := cmd.CombinedOutput()
|
|
out, err := cmd.CombinedOutput()
|
|
if err != nil {
|
|
if err != nil {
|