MEAN and STD values in TensorFlow Lite Micro for i.MXRT tutorial

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MEAN and STD values in TensorFlow Lite Micro for i.MXRT tutorial

ソリューションへジャンプ
3,436件の閲覧回数
MarcinChelminsk
Contributor IV

Hello!

question in regards to Getting Started with TensorFlow Lite for Microcontrollers on i.MX RT

there are two defines in section 4.1 (with camera version)

 

 

#define MODEL_INPUT_MEAN 127.5f
#define MODEL_INPUT_STD 127.5f

 

 

 however when you run flower_lab.py  (with small changes highlighted with "CHANGE", they aim to check what are mean/std values)

 

 

#Retrain model on new images
mobilenetv1_spec = model_spec.ImageModelSpec(uri='https://tfhub.dev/google/imagenet/mobilenet_v1_025_128/feature_vector/4')
print("MEAN", mobilenetv1_spec.mean_rgb) #CHANGE
print("STD", mobilenetv1_spec.stddev_rgb) #CHANGE 
mobilenetv1_spec.input_image_shape = [128, 128]
model = image_classifier.create(train_data, model_spec=mobilenetv1_spec, validation_data=validation_data)
model.summary()

 

 

 it prints out that during retraining the values took into account are:

 

 

MEAN [0.0]
STD [255.0]

 

 

Therefore, when I changed in MCUXpresso following defines to

 

 

#define MODEL_INPUT_MEAN 0.0f
#define MODEL_INPUT_STD 255.0f

 

 

results of inferencing are better, in my subjective opinion, it means model is more confident that sunflower or for example does not mixing dandelion with sunflower (when looking at dandelion)

What you think?

0 件の賞賛
1 解決策
3,299件の閲覧回数
david_piskula
NXP Employee
NXP Employee

Hi @MarcinChelminsk, thanks for noticing this. The MEAN and STD used during training must equal the MEAN and STD used during inference. We'll need to fix the typo in the lab.

元の投稿で解決策を見る

2 返答(返信)
3,239件の閲覧回数
MarcinChelminsk
Contributor IV

@david_piskula, thanks for feedback! I see that Getting Started with TensorFlow Lite for Microcontrollers on i.MX RT has been updated already, great!

0 件の賞賛
3,300件の閲覧回数
david_piskula
NXP Employee
NXP Employee

Hi @MarcinChelminsk, thanks for noticing this. The MEAN and STD used during training must equal the MEAN and STD used during inference. We'll need to fix the typo in the lab.