gpt4 book ai didi

python - 如何在GoCV中提取信心

转载 作者:行者123 更新时间:2023-12-01 22:20:48 25 4
gpt4 key购买 nike

我尝试使用Golang来重新制作Python ver Mask Detector,而我却被GoCV困住了“Extract Confidence”,它像这样说的python代码

detections = net.forward()

# loop over the detections
for i in range(0, detections.shape[2]):
# extract the confidence (i.e., probability) associated with
# the detection
confidence = detections[0, 0, i, 2]
它在python上工作正常,但是我如何使用GoCV获得信心值?
这是我目前的工作
    currPath := "/media/fz/Project (Running)/Unknown/TryDetectMask/face_detector"
prototxtPath := path.Join(currPath, "deploy.prototxt")
weightsPath := path.Join(currPath, "res10_300x300_ssd_iter_140000.caffemodel")
//definedConfidence := 0.5
//modelPath := "mask_detector.model"

net := gocv.ReadNet(prototxtPath, weightsPath)

//model, _ := tf.LoadSavedModel(modelPath, []string{"serve"}, nil)
img := gocv.IMRead("/home/fz/Desktop/download.jpeg", gocv.IMReadUnchanged)

//orig := img.CopyTo
//imgSize := img.Size()

img.ConvertTo(&img, gocv.MatTypeCV32F)
imgBlob := gocv.BlobFromImage(img, 1.0, image.Point{X: 300, Y: 300}, gocv.NewScalar(104.0, 177.0, 123.0, 0), false, false)

net.SetInput(imgBlob, "")
detections := net.Forward("")

//a, _ := detections.FromPtr(1,1,gocv.MatTypeCV32F,1,2)
fmt.Printf("%v", detections.Total())

//detectionsMat := detections.Reshape(1,1)
//_, maxVal, _, maxLoc := gocv.MinMaxLoc(detectionsMat)
//
//fmt.Println(maxVal)
//fmt.Println(maxLoc.X)

最佳答案

我使用此行代码成功完成此操作

detections := net.Forward("")

for i := 0; i < detections.Total(); i += 7 {
confidence := detections.GetFloatAt(0, i+2)

关于python - 如何在GoCV中提取信心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63625408/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com