refactor: inference result
This commit is contained in:
parent
c5c87da714
commit
ce58df8a6d
@ -211,17 +211,19 @@ func (p *Part) Value(img image.Image) (float32, float32, error) {
|
|||||||
return 0., 0., fmt.Errorf("invoke failed: %v", status)
|
return 0., 0., fmt.Errorf("invoke failed: %v", status)
|
||||||
}
|
}
|
||||||
|
|
||||||
output := p.interpreter.GetOutputTensor(0)
|
output := p.interpreter.GetOutputTensor(0).Int8s()
|
||||||
|
zap.L().Debug("raw steering", zap.Int8s("result", output))
|
||||||
|
|
||||||
outputSize := output.Dim(output.NumDims() - 1)
|
//outputSize := output.Dim(output.NumDims() - 1)
|
||||||
|
|
||||||
b := make([]byte, outputSize)
|
//b := make([]byte, outputSize)
|
||||||
status = output.CopyToBuffer(&b[0])
|
//status = output.CopyToBuffer(&b[0])
|
||||||
if status != tflite.OK {
|
//if status != tflite.OK {
|
||||||
return 0., 0., fmt.Errorf("output failed: %v", status)
|
// return 0., 0., fmt.Errorf("output failed: %v", status)
|
||||||
}
|
//}
|
||||||
|
|
||||||
steering, score := tools.LinearBin(b, 15, -1, 2.0)
|
steering, score := tools.LinearBin(output, 15, -1, 2.0)
|
||||||
|
//steering, score := tools.LinearBin(b, 15, -1, 2.0)
|
||||||
zap.L().Debug("found steering",
|
zap.L().Debug("found steering",
|
||||||
zap.Float64("steering", steering),
|
zap.Float64("steering", steering),
|
||||||
zap.Float64("score", score),
|
zap.Float64("score", score),
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// LinearBin perform inverse linear_bin, taking
|
// LinearBin perform inverse linear_bin, taking
|
||||||
func LinearBin(arr []byte, n int, offset int, r float64) (float64, float64) {
|
func LinearBin(arr []int8, n int, offset int, r float64) (float64, float64) {
|
||||||
outputSize := len(arr)
|
outputSize := len(arr)
|
||||||
type result struct {
|
type result struct {
|
||||||
score float64
|
score float64
|
||||||
@ -17,7 +17,7 @@ func LinearBin(arr []byte, n int, offset int, r float64) (float64, float64) {
|
|||||||
var results []result
|
var results []result
|
||||||
minScore := 0.2
|
minScore := 0.2
|
||||||
for i := 0; i < outputSize; i++ {
|
for i := 0; i < outputSize; i++ {
|
||||||
score := float64(arr[i]) / 255.0
|
score := float64(int(arr[i])+128) / 255.0
|
||||||
if score < minScore {
|
if score < minScore {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user