@@ -73,25 +73,26 @@ export function stage1(
73
73
) {
74
74
stats . stage1 = [ ]
75
75
76
- const boxesForScale = scales . map ( ( scale ) => {
76
+ const pnetOutputs = scales . map ( ( scale ) => tf . tidy ( ( ) => {
77
77
const statsForScale : any = { scale }
78
+ const resized = rescaleAndNormalize ( imgTensor , scale )
78
79
79
- const { scoresTensor, regionsTensor } = tf . tidy ( ( ) => {
80
- const resized = rescaleAndNormalize ( imgTensor , scale )
81
-
82
- let ts = Date . now ( )
83
- const { prob, regions } = PNet ( resized , params )
84
- statsForScale . pnet = Date . now ( ) - ts
80
+ let ts = Date . now ( )
81
+ const { prob, regions } = PNet ( resized , params )
82
+ statsForScale . pnet = Date . now ( ) - ts
85
83
86
- const scoresTensor = tf . unstack ( tf . unstack ( prob , 3 ) [ 1 ] ) [ 0 ] as tf . Tensor2D
87
- const regionsTensor = tf . unstack ( regions ) [ 0 ] as tf . Tensor3D
84
+ const scoresTensor = tf . unstack ( tf . unstack ( prob , 3 ) [ 1 ] ) [ 0 ] as tf . Tensor2D
85
+ const regionsTensor = tf . unstack ( regions ) [ 0 ] as tf . Tensor3D
88
86
89
- return {
90
- scoresTensor,
91
- regionsTensor
92
- }
93
- } )
87
+ return {
88
+ scoresTensor,
89
+ regionsTensor,
90
+ scale,
91
+ statsForScale
92
+ }
93
+ } ) )
94
94
95
+ const boxesForScale = pnetOutputs . map ( ( { scoresTensor, regionsTensor, scale, statsForScale } ) => {
95
96
const boundingBoxes = extractBoundingBoxes (
96
97
scoresTensor ,
97
98
regionsTensor ,
@@ -121,7 +122,7 @@ export function stage1(
121
122
} )
122
123
123
124
const allBoxes = boxesForScale . reduce (
124
- ( all , boxes ) => all . concat ( boxes )
125
+ ( all , boxes ) => all . concat ( boxes ) , [ ]
125
126
)
126
127
127
128
let finalBoxes : BoundingBox [ ] = [ ]
0 commit comments