change(example/yolo)

This commit is contained in:
sugarme 2020-07-16 12:49:46 +10:00
parent e7727b930f
commit e1469f05fd

View File

@ -139,7 +139,6 @@ func report(pred ts.Tensor, img ts.Tensor, w int64, h int64) (retVal ts.Tensor)
}
// 3. Truncate at currentIndex (exclusive)
if currentIndex < len(bboxesForClass) {
// bboxesForClass = append(bboxesForClass[:currentIndex], bboxesForClass[currentIndex+1:]...)
bboxesForClass = append(bboxesForClass[:currentIndex])
}
@ -169,6 +168,9 @@ func report(pred ts.Tensor, img ts.Tensor, w int64, h int64) (retVal ts.Tensor)
xmax := min(max(int64(b.xmax*wRatio), 0), (initialW - 1))
ymax := min(max(int64(b.ymax*hRatio), 0), (initialH - 1))
fmt.Printf("xmin: %v\n", xmin)
fmt.Printf("ymin: %v\n", ymin)
// draw rect
drawRect(image, xmin, xmax, ymin, min(ymax, ymin+2))
drawRect(image, xmin, xmax, max(ymin, ymax-2), ymax)
@ -255,6 +257,10 @@ func main() {
if err != nil {
log.Fatal(err)
}
// TODO: write label/confidence val next to bouding boxes.
// Naive way is write 'write text on image' rather than on tensor.
// See this: https://stackoverflow.com/questions/38299930
}
func max(v1, v2 int64) (retVal int64) {