PINTO0309 / PINTO_model_zoo

A repository for storing models that have been inter-converted between various frameworks. Supported frameworks are TensorFlow, PyTorch, ONNX, OpenVINO, TFJS, TFTRT, TensorFlowLite (Float32/16/INT8), EdgeTPU, CoreML.
https://qiita.com/PINTO
MIT License
3.59k stars 572 forks source link

Empty prior bboxes in 227_face-detection-adas-0001 #306

Closed PCTsai closed 1 year ago

PCTsai commented 2 years ago

Issue Type

Support

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

TensorFlowLite

Model name and Weights/Checkpoints URL

https://github.com/PINTO0309/PINTO_model_zoo/tree/main/227_face-detection-adas-0001

Description

Hi PINTO, I'm trying to run the face detection model followed by the issue response and the sample code. The output bboxes seem ok but the corresponding prior bboxes is always zero (i.e. [0,0,0,0]) which causes zero decoded bbox for the final result. I had checked the prior bboxes loaded from 0.npy where totally number is 10112 and found 10105 zero bboxes. Is this prior bboxes file 0.npy correct for this model?

Relevant Log Output

No response

URL or source code for simple inference testing code

No response

PINTO0309 commented 2 years ago

https://github.com/PINTO0309/PINTO_model_zoo/tree/main/227_face-detection-adas-0001

>>> import numpy as np
>>> np.load('0.npy')
array([[[0.9796773, 0.9497039, 0.9965132, ..., 0.       , 0.       ,
         0.       ],
        [0.1      , 0.1      , 0.2      , ..., 0.1      , 0.2      ,
         0.2      ]]], dtype=float32)
>>> np.load('0.npy').shape
(1, 2, 40448)
>>> 
PCTsai commented 2 years ago

Yes, the data dimension in the file 0.npy is (1, 2, 40448). As I know is that it consists of 10112 prior bboxes and 10112 corresponding prior variances (always [0.1, 0.1, 0.2, 0.2]). After squeezing and reshaping the loaded data as shown in the below code, it is clear to see that data in prior bboxes is almost empty (10105 zero prior bboxes), that means the decoded bboxes will be also empty and face detection will fail. However, 0.npy in 179_person-detection-0202 is not empty and works well.

>>> import numpy as np
>>> np.load("0.npy")
array([[[0.9796773, 0.9497039, 0.9965132, ..., 0.       , 0.       ,
         0.       ],
        [0.1      , 0.1      , 0.2      , ..., 0.1      , 0.2      ,
         0.2      ]]], dtype=float32)
>>> np.load("0.npy").shape
(1, 2, 40448)
>>> prior_bbox_data = np.squeeze(np.load("0.npy"))
>>> prior_bbox_data
array([[0.9796773, 0.9497039, 0.9965132, ..., 0.       , 0.       ,
        0.       ],
       [0.1      , 0.1      , 0.2      , ..., 0.1      , 0.2      ,
        0.2      ]], dtype=float32)
>>> prior_bbox_data.shape
(2, 40448)
>>> prior_bbox_data_reshape = np.reshape(prior_bbox_data, (2, -1, 4))
>>> prior_bbox_data_reshape
array([[[0.9796773, 0.9497039, 0.9965132, 1.0086294],
        [0.       , 0.       , 0.       , 0.       ],
        [0.       , 0.       , 0.       , 0.       ],
        ...,
        [0.       , 0.       , 0.       , 0.       ],
        [0.       , 0.       , 0.       , 0.       ],
        [0.       , 0.       , 0.       , 0.       ]],

       [[0.1      , 0.1      , 0.2      , 0.2      ],
        [0.1      , 0.1      , 0.2      , 0.2      ],
        [0.1      , 0.1      , 0.2      , 0.2      ],
        ...,
        [0.1      , 0.1      , 0.2      , 0.2      ],
        [0.1      , 0.1      , 0.2      , 0.2      ],
        [0.1      , 0.1      , 0.2      , 0.2      ]]], dtype=float32)
>>> prior_bbox_data_reshape.shape
(2, 10112, 4)
>>> prior_bbox = prior_bbox_data_reshape[0]
>>> prior_bbox
array([[0.9796773, 0.9497039, 0.9965132, 1.0086294],
       [0.       , 0.       , 0.       , 0.       ],
       [0.       , 0.       , 0.       , 0.       ],
       ...,
       [0.       , 0.       , 0.       , 0.       ],
       [0.       , 0.       , 0.       , 0.       ],
       [0.       , 0.       , 0.       , 0.       ]], dtype=float32)
>>> prior_varience = prior_bbox_data_reshape[1]
>>> prior_varience
array([[0.1, 0.1, 0.2, 0.2],
       [0.1, 0.1, 0.2, 0.2],
       [0.1, 0.1, 0.2, 0.2],
       ...,
       [0.1, 0.1, 0.2, 0.2],
       [0.1, 0.1, 0.2, 0.2],
       [0.1, 0.1, 0.2, 0.2]], dtype=float32)
>>> 
PINTO0309 commented 1 year ago

The model is too old to retrieve the original file.

I recommend the use of the following https://github.com/PINTO0309/PINTO_model_zoo/tree/main/383_DirectMHP

https://github.com/PINTO0309/PINTO_model_zoo/assets/33194443/1c125faa-b2c3-4acc-a4c5-d1fc2e2b47a3

https://github.com/PINTO0309/PINTO_model_zoo/tree/main/407_Generalizing_Gaze_Estimation

https://github.com/PINTO0309/PINTO_model_zoo/assets/33194443/2da9849a-944d-4bc1-a975-f4cf1bcfc398