ESP32部署TensorFlow Lite

本来是想找一篇中文教程,不过只看到一个英文官方的,也行吧,虽然效率会慢丢丢。

GitHub - espressif/esp-tflite-micro: TensorFlow Lite Micro for Espressif Chipsets

看了一圈,有个中文的:

esp-dl/README_cn.md at master · espressif/esp-dl · GitHub

目前阶段还是照着做,然后写一点感想。。。后面有机会和能力再深度写一下。

之前都是用micropython,觉得简单。不过涉及到tensorflow lite的好像都是原厂环境。。。

没办法,搞了一阵终于把环境弄出来了。可以Hello了。。。

继续往机器学习的方向走,遇到的最大的问题就是不管是tensorflow还是tflite-micro,都无法下载。但是网上的很多教程都是先要拿到tensorflow lite。然后基于tensorflow lite的例子,送到idf环境去编译。

后面看了历险记(参考中)那个文章,说是现在乐鑫自己也有tflite的例子,可以曲线救国,先跑通乐鑫自己的例子,然后用python下的tensorflow生成lite模型,最后用xxd命令转换成model.cc。这个model.cc刚好又是乐鑫里面带了的。这样就可以闭环了。

照着他写的一步步来,晚上把乐鑫自己的hello world跑通了,还是很简单。(真不知道网上这些大神哪里找的教程,我是翻了半天都没翻到)

又试了下用tensorflow生成模型(生成模型和转换是在ubuntu上做的哈):

import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import mathx_values = np.random.uniform(low=0, high=2 * math.pi, size=1000).astype(np.float32)np.random.shuffle(x_values)y_values = np.sin(x_values).astype(np.float32)plt.plot(x_values, y_values,"b.")
plt.show()y_values += 0.1 * np.random.randn(*y_values.shape)plt.plot(x_values, y_values, "b.")
plt.show()TRAIN_SPLIT = int(0.6 * 1000)
TEST_SPLIT = int(0.2 * 1000 + TRAIN_SPLIT)x_train, x_validate, x_test = np.split(x_values, [TRAIN_SPLIT, TEST_SPLIT])
y_train, y_validate, y_test = np.split(y_values, [TRAIN_SPLIT, TEST_SPLIT])plt.plot(x_train, y_train, "b.", label="Train")
plt.plot(x_validate, y_validate, "y.", label="Validate")
plt.plot(x_test, y_test, "r.", label="Test")
plt.legend()
plt.show()model = tf.keras.Sequential()# First layer takes a scalar input and feeds it through 16 "neurons". The
# neurons decide whether to activate based on the 'relu' activation function.
model.add(tf.keras.layers.Dense(16, activation='relu', input_shape=(1,)))# The new second and third layer will help the network learn more complex
# representations
model.add(tf.keras.layers.Dense(16, activation='relu'))# Final layer is a single neuron, since we want to output a single value
model.add(tf.keras.layers.Dense(1))# Compile the model using the standard 'adam' optimizer and the mean squared
# error or 'mse' loss function for regression.
model.compile(optimizer='adam', loss='mse', metrics=['mae'])
model.summary()model.fit(x_values,y_values,epochs=400,validation_split=0.2,batch_size=64,verbose=2)
save_dir = './modes/test'
tf.saved_model.save(model, save_dir)converter = tf.lite.TFLiteConverter.from_saved_model(save_dir)
tflite_model = converter.convert()import pathlibtflite_model_file = pathlib.Path('model.tflite')
tflite_model_file.write_bytes(tflite_model)def representative_dataset(num_samples=500):for i in range(num_samples):yield [x_values[i].reshape(1, 1)]saved_model_dir = "./modes/test"
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
converter.inference_input_type = tf.int8
converter.inference_output_type = tf.int8
converter.representative_dataset = representative_dataset
tflite_quant_model = converter.convert()
open("sine_model_quantized.tflite","wb").write(tflite_quant_model)

运行python之后生成sine_model_quantized.tflite

按照例程中说的安装xdd

sudo apt install xxd

然后运行转换命令。xdd命令也没什么特别的,就是在Linux中用于以二进制或十六进制显示文件的内容。-i 选项允许以C语言风格的数组形式输出文件内容。就是把二进制转成C的数组。

xxd -i sine_model_quantized.tflite > model.cc

之后把model.cc拷贝回esp32的hello world环境。但是代码要稍微改改,主要是要把模型数组换成g_model,否则要报错。

model.cc

#include "model.h"alignas(8) const unsigned char g_model[] = {0x20, 0x00, 0x00, 0x00, 0x54, 0x46, 0x4c, 0x33, 0x00, 0x00, 0x00, 0x00,0x14, 0x00, 0x20, 0x00, 0x1c, 0x00, 0x18, 0x00, 0x14, 0x00, 0x10, 0x00,0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00,0x1c, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0xe8, 0x00, 0x00, 0x00,0xa4, 0x03, 0x00, 0x00, 0xb4, 0x03, 0x00, 0x00, 0x0c, 0x0a, 0x00, 0x00,0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x04, 0x00,0x0a, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,0x38, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x73, 0x65, 0x72, 0x76,0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00,0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x98, 0xff, 0xff, 0xff,0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x32, 0x00, 0x01, 0x00, 0x00, 0x00,0x04, 0x00, 0x00, 0x00, 0xea, 0xfc, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00,0x0b, 0x00, 0x00, 0x00, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x69, 0x6e,0x70, 0x75, 0x74, 0x00, 0x02, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,0x04, 0x00, 0x00, 0x00, 0xdc, 0xff, 0xff, 0xff, 0x0c, 0x00, 0x00, 0x00,0x04, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x43, 0x4f, 0x4e, 0x56,0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x4d, 0x45, 0x54, 0x41, 0x44,0x41, 0x54, 0x41, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x04, 0x00,0x08, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,0x13, 0x00, 0x00, 0x00, 0x6d, 0x69, 0x6e, 0x5f, 0x72, 0x75, 0x6e, 0x74,0x69, 0x6d, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00,0x0d, 0x00, 0x00, 0x00, 0xb8, 0x02, 0x00, 0x00, 0xb0, 0x02, 0x00, 0x00,0x9c, 0x02, 0x00, 0x00, 0x74, 0x02, 0x00, 0x00, 0x24, 0x02, 0x00, 0x00,0x14, 0x01, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00,0x9c, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00,0x6c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x96, 0xfd, 0xff, 0xff,0x04, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,0x08, 0x00, 0x0e, 0x00, 0x08, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00,0x10, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,0x01, 0x00, 0x00, 0x00, 0xeb, 0x03, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00,0x10, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00,0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,0x06, 0x00, 0x00, 0x00, 0x32, 0x2e, 0x31, 0x33, 0x2e, 0x31, 0x00, 0x00,0xfa, 0xfd, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,0x31, 0x2e, 0x31, 0x34, 0x2e, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x84, 0xfd, 0xff, 0xff, 0x88, 0xfd, 0xff, 0xff,0x8c, 0xfd, 0xff, 0xff, 0x22, 0xfe, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00,0x10, 0x00, 0x00, 0x00, 0x81, 0x87, 0x92, 0x83, 0x60, 0x58, 0xc4, 0x24,0xa3, 0x72, 0xaf, 0x32, 0x94, 0x9d, 0x30, 0xe8, 0x3e, 0xfe, 0xff, 0xff,0x04, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0xf2, 0x08, 0x00, 0x00, 0xb0, 0xf7, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,0x8c, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x31, 0xff, 0xff, 0xff,0x00, 0x00, 0x00, 0x00, 0x97, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x17, 0xf6, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,0x8a, 0xfe, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,0x44, 0xdb, 0xdb, 0x31, 0x2d, 0xf6, 0xfa, 0xba, 0x33, 0x09, 0xd7, 0x48,0xed, 0xcd, 0xc7, 0x21, 0x4d, 0x39, 0x14, 0x23, 0x16, 0x15, 0xb6, 0x40,0x37, 0x4f, 0xf0, 0xbc, 0xf2, 0xe5, 0xd6, 0xeb, 0xdf, 0xe7, 0x11, 0xf2,0x1d, 0x44, 0xde, 0x34, 0xf8, 0xda, 0xc2, 0x24, 0x05, 0x00, 0x32, 0xf3,0xd2, 0xeb, 0xbf, 0xe7, 0xf6, 0x34, 0xd9, 0x36, 0xb7, 0x14, 0x27, 0x0e,0xb1, 0x31, 0xf4, 0x22, 0xf1, 0x47, 0xd0, 0x08, 0x09, 0x15, 0x4c, 0x5c,0x39, 0x3f, 0x2f, 0xce, 0x0f, 0xdc, 0x20, 0x0b, 0x53, 0xf5, 0x33, 0x08,0xe8, 0x46, 0x13, 0x10, 0xf9, 0xc0, 0x29, 0x21, 0xd2, 0xd0, 0xf4, 0x37,0xee, 0xcc, 0xb5, 0xb5, 0xbf, 0x22, 0x2a, 0x3c, 0x39, 0x37, 0xfc, 0xb8,0x0d, 0x22, 0xba, 0xc6, 0xd0, 0x1e, 0xc0, 0x1a, 0xfc, 0xb2, 0xdc, 0xf7,0x34, 0x36, 0xe4, 0xdd, 0xcb, 0x32, 0xd4, 0x4d, 0x01, 0xf5, 0xbf, 0xc2,0xdd, 0xd8, 0xe7, 0xea, 0xcc, 0x39, 0xea, 0xcb, 0x11, 0x20, 0x33, 0xd9,0xbf, 0xce, 0xf5, 0x2e, 0x0f, 0x5e, 0x53, 0x0a, 0xd2, 0xe4, 0x1c, 0x1d,0x46, 0x0d, 0x39, 0xc7, 0xae, 0xb5, 0x40, 0xc0, 0x05, 0xba, 0x3a, 0xfe,0xca, 0x81, 0xd7, 0xa4, 0x09, 0xef, 0xee, 0x14, 0x29, 0xc6, 0x0c, 0xf2,0xe2, 0x20, 0xe3, 0xf9, 0xec, 0x42, 0x51, 0x46, 0xc7, 0xcd, 0x48, 0xe7,0x41, 0xd3, 0x40, 0xf9, 0xe2, 0x50, 0x02, 0xdc, 0x39, 0xb7, 0x15, 0xd1,0xe1, 0x34, 0x35, 0x0b, 0xeb, 0x0d, 0x0a, 0xcd, 0xf8, 0x0e, 0xb4, 0x1a,0xd3, 0xf8, 0xce, 0xb1, 0xee, 0x43, 0xbb, 0x4b, 0x2f, 0x18, 0x3e, 0x2d,0x33, 0x0f, 0x40, 0x3d, 0x02, 0xcd, 0xe1, 0xab, 0x29, 0xb7, 0x22, 0x41,0xe2, 0x49, 0x4b, 0x35, 0x20, 0xed, 0x50, 0xe4, 0x41, 0x24, 0xf7, 0x31,0x1d, 0xdf, 0xb8, 0xfa, 0x96, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00,0x40, 0x00, 0x00, 0x00, 0xe6, 0x0b, 0x00, 0x00, 0xcd, 0xf2, 0xff, 0xff,0x10, 0xf5, 0xff, 0xff, 0x05, 0x0b, 0x00, 0x00, 0xb0, 0xf6, 0xff, 0xff,0x89, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xb0, 0xfe, 0xff, 0xff,0x00, 0x00, 0x00, 0x00, 0x45, 0xf5, 0xff, 0xff, 0x50, 0x1c, 0x00, 0x00,0x6f, 0xef, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0xfe, 0xfe, 0xff, 0xff, 0x31, 0x0c, 0x00, 0x00, 0xe2, 0xff, 0xff, 0xff,0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x50, 0xd0, 0xe9, 0x0b,0xbb, 0xcd, 0xe8, 0xfd, 0xca, 0xf0, 0x81, 0xd9, 0xfe, 0xe9, 0xe4, 0x32,0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00,0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xb0, 0x0a, 0x00, 0x00,0x84, 0xff, 0xff, 0xff, 0x88, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00,0x4d, 0x4c, 0x49, 0x52, 0x20, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74,0x65, 0x64, 0x2e, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x14, 0x00, 0x10, 0x00, 0x0c, 0x00,0x08, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,0x1c, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00,0xe4, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e,0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00,0x3c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x96, 0xff, 0xff, 0xff,0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x00,0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00,0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,0xca, 0xff, 0xff, 0xff, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xba, 0xff, 0xff, 0xff,0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x16, 0x00, 0x00, 0x00,0x10, 0x00, 0x0c, 0x00, 0x0b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00,0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x18, 0x00, 0x00, 0x00,0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x07, 0x00,0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x06, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,0x09, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x0a, 0x00, 0x00, 0x00, 0xbc, 0x04, 0x00, 0x00, 0x2c, 0x04, 0x00, 0x00,0xa8, 0x03, 0x00, 0x00, 0x2c, 0x03, 0x00, 0x00, 0xc0, 0x02, 0x00, 0x00,0x4c, 0x02, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x34, 0x01, 0x00, 0x00,0x80, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x82, 0xfb, 0xff, 0xff,0x00, 0x00, 0x00, 0x01, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,0x3c, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,0x50, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,0x01, 0x00, 0x00, 0x00, 0x6c, 0xfb, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00,0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0xee, 0x06, 0x3c,0x19, 0x00, 0x00, 0x00, 0x53, 0x74, 0x61, 0x74, 0x65, 0x66, 0x75, 0x6c,0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x65, 0x64, 0x43,0x61, 0x6c, 0x6c, 0x3a, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xfa, 0xfb, 0xff, 0xff,0x00, 0x00, 0x00, 0x01, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,0x40, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,0x88, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,0x10, 0x00, 0x00, 0x00, 0xe4, 0xfb, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00,0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,0x13, 0xa5, 0xce, 0x3b, 0x4c, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75,0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65,0x5f, 0x31, 0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x3b, 0x73, 0x65,0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x2f, 0x64, 0x65, 0x6e,0x73, 0x65, 0x5f, 0x31, 0x2f, 0x52, 0x65, 0x6c, 0x75, 0x3b, 0x73, 0x65,0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x2f, 0x64, 0x65, 0x6e,0x73, 0x65, 0x5f, 0x31, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41, 0x64, 0x64,0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,0x10, 0x00, 0x00, 0x00, 0xaa, 0xfc, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01,0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x80, 0x00, 0x00, 0x00,0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x10, 0x00, 0x00, 0x00,0x94, 0xfc, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,0x01, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x2c, 0x46, 0x3c,0x46, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,0x61, 0x6c, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x2f, 0x4d, 0x61, 0x74,0x4d, 0x75, 0x6c, 0x3b, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,0x61, 0x6c, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x2f, 0x52, 0x65, 0x6c,0x75, 0x3b, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c,0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41,0x64, 0x64, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,0x10, 0x00, 0x00, 0x00, 0xde, 0xfd, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01,0x14, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x09, 0x44, 0x00, 0x00, 0x00, 0x2c, 0xfd, 0xff, 0xff,0x08, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x01, 0x00, 0x00, 0x00, 0x01, 0xc6, 0x8e, 0x3b, 0x17, 0x00, 0x00, 0x00,0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x2f, 0x64,0x65, 0x6e, 0x73, 0x65, 0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x00,0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,0x46, 0xfe, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x14, 0x00, 0x00, 0x00,0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,0x50, 0x00, 0x00, 0x00, 0x94, 0xfd, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00,0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0xf8, 0xe0, 0x38,0x27, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,0x61, 0x6c, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x2f, 0x42, 0x69, 0x61,0x73, 0x41, 0x64, 0x64, 0x2f, 0x52, 0x65, 0x61, 0x64, 0x56, 0x61, 0x72,0x69, 0x61, 0x62, 0x6c, 0x65, 0x4f, 0x70, 0x00, 0x01, 0x00, 0x00, 0x00,0x10, 0x00, 0x00, 0x00, 0xb6, 0xfe, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01,0x14, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x09, 0x44, 0x00, 0x00, 0x00, 0x04, 0xfe, 0xff, 0xff,0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,0x43, 0x4f, 0xa9, 0x3b, 0x19, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75,0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65,0x5f, 0x31, 0x2f, 0x4d, 0x61, 0x74, 0x4d, 0x75, 0x6c, 0x00, 0x00, 0x00,0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,0x1e, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x14, 0x00, 0x00, 0x00,0x34, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,0x58, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00,0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,0x71, 0x10, 0x83, 0x38, 0x29, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75,0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65,0x5f, 0x31, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41, 0x64, 0x64, 0x2f, 0x52,0x65, 0x61, 0x64, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x4f,0x70, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,0x96, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x14, 0x00, 0x00, 0x00,0x30, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,0x44, 0x00, 0x00, 0x00, 0xe4, 0xfe, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00,0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6e, 0x72, 0x29, 0x3c,0x19, 0x00, 0x00, 0x00, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69,0x61, 0x6c, 0x2f, 0x64, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x32, 0x2f, 0x4d,0x61, 0x74, 0x4d, 0x75, 0x6c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00,0x1c, 0x00, 0x18, 0x00, 0x17, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x08, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x16, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x01, 0x14, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x54, 0x00, 0x00, 0x00,0x64, 0xff, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x01, 0x00, 0x00, 0x00, 0x58, 0xc7, 0x88, 0x38, 0x29, 0x00, 0x00, 0x00,0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x2f, 0x64,0x65, 0x6e, 0x73, 0x65, 0x5f, 0x32, 0x2f, 0x42, 0x69, 0x61, 0x73, 0x41,0x64, 0x64, 0x2f, 0x52, 0x65, 0x61, 0x64, 0x56, 0x61, 0x72, 0x69, 0x61,0x62, 0x6c, 0x65, 0x4f, 0x70, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x20, 0x00, 0x1c, 0x00,0x1b, 0x00, 0x14, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,0x08, 0x00, 0x07, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,0x18, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00,0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x64, 0x00, 0x00, 0x00,0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,0x0c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00,0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,0x01, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xcb, 0xb0, 0xc9, 0x3c,0x1d, 0x00, 0x00, 0x00, 0x73, 0x65, 0x72, 0x76, 0x69, 0x6e, 0x67, 0x5f,0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x64, 0x65, 0x6e, 0x73,0x65, 0x5f, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x3a, 0x30, 0x00, 0x00, 0x00,0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x10, 0x00,0x0f, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00,0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09
};
unsigned int sine_model_quantized_tflite_len = 2664;const int g_model_len = 2664;

然后就是编译三部曲:

idf.py set-target esp32
idf.py build
idf.py flash monitor

最后就能看到结果:

好吧,虽然还是很low,全部都只是照着弄,但是总算是跑通了。我有时候甚至觉得搭建环境算是成功了一半。。。接着有时间我会慢慢来分析分析的。

https://github.com/espressif/esp-tflite-micro/tree/master

https://github.com/tensorflow/tflite-micro

参考:

Windows 平台工具链的标准设置 - ESP32 - — ESP-IDF 编程指南 v5.2.2 文档

ESPFriends之ESP32模型部署训练历险记(一)_terserflowlite部署esp32-CSDN博客

【TinyML】用ESP32实现弱监督人体定位

最简单体验TinyML、TensorFlow Lite——ESP32跑机器学习(全代码)-CSDN博客

ESPFriends之ESP32模型部署训练历险记(一)_terserflowlite部署esp32-CSDN博客

Tensorflow Lite从入门到精通-CSDN博客

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://xiahunao.cn/news/3246482.html

如若内容造成侵权/违法违规/事实不符,请联系瞎胡闹网进行投诉反馈,一经查实,立即删除!

相关文章

C语言 ——— 编写代码,判断 整型数组 是否 有序

目录 题目要求 代码实现 题目要求 判断 整型数组 是否有序 如果 整型数组 有序输出 sorted&#xff1b;否则输出 unsorted 代码实现 #include<stdio.h> int main() {int arr[10] { 0 };int sz sizeof(arr) / sizeof(arr[0]);//输入for (int i 0; i < sz; i){s…

5个超牛的Java开源OA项目(强烈推荐)

1. O2OA ——开源地址&#xff1a;https://gitee.com/o2oa/O2OA 概述&#xff1a; O2OA 是一款真正全代码&#xff08;包含服务器、安卓以及IOS客户端&#xff09;开源的企业应用定制化开发平台&#xff0c;适用于企业OA、协同办公类信息化系统的建设和开发。技术&#xff1a;…

【JavaScript 算法】栈与队列:解决括号匹配问题

&#x1f525; 个人主页&#xff1a;空白诗 文章目录 一、算法原理二、算法实现三、应用场景四、总结 在编程中&#xff0c;括号匹配问题是一类常见的算法题&#xff0c;通常用于验证括号的正确性&#xff0c;即检查括号是否成对出现且嵌套正确。栈&#xff08;Stack&#xff0…

Uniapp基础篇(持续更新)

1. Uni-app常用内置组件 view 视图容器 scroll-view 可滚动视图区域&#xff0c;用于区域滚动。需注意在webview渲染的页面中&#xff0c;区域滚动的性能不及页面滚动。 swiper 滑块视图容器。一般用于左右滑动或上下滑动&#xff0c;比如banner轮播图。 image uniapp官方iam…

软件测试——非功能测试

工作职责&#xff1a; 1.负责产品系统测试&#xff0c;包括功能测试、性能测试、稳定性测试、用户场景测试、可靠性测试等。 2.负责测试相关文档的编写&#xff0c;包括测试计划、测试用例、测试报告等。 3.负责自动化测试框架、用例的维护。 岗位要求&#xff1a; 1.熟练…

微软的vscode和vs2022快捷键官网链接

vscode官方文档:https://code.visualstudio.com/docs/ vscode快捷键官方文档:https://code.visualstudio.com/docs/getstarted/keybindings vs2022官方文档:https://learn.microsoft.com/zh-cn/visualstudio/ide/?viewvs-2022 vscode快捷键官方文档:https://learn.microsoft.c…

Spring Cloud环境搭建

&#x1f3a5; 个人主页&#xff1a;Dikz12&#x1f525;个人专栏&#xff1a;Spring学习之路&#x1f4d5;格言&#xff1a;吾愚多不敏&#xff0c;而愿加学欢迎大家&#x1f44d;点赞✍评论⭐收藏 目录 1. 开发环境安装 1.1 安装JDK ​1.2 安装MySQL 2. 案列介绍 2.1 …

【顺序表】算法题 --- 力扣

一、移除元素 移除元素 这个题让我们移除数组nums中值为val的元素&#xff0c;最后返回k&#xff08;不是val的元素个数&#xff09; 这样显然我们就不能再创建一个数组来解决这个问题了&#xff0c;只能另辟蹊径 思路&#xff1a;双指针 这里定义两个指针&#xff08;l1&…

解决Ubuntu 20.04下外接显示屏无信号问题【多次尝试无坑完整版!!!】

解决Ubuntu 20.04下外接显示屏无信号问题【多次尝试无坑完整版&#xff01;&#xff01;&#xff01;】 一、引言 作为一名开发者&#xff0c;我经常在Windows和Ubuntu之间切换&#xff0c;以满足不同的开发需求。最近&#xff0c;我在使用惠普暗影精灵9&#xff08;搭载RTX 4…

算法力扣刷题记录 四十九【112. 路径总和】和【113. 路径总和ii】

前言 二叉树篇继续。 记录 四十九【112. 路径总和】和【113. 路径总和ii】 一、【112. 路径总和】题目阅读 给你二叉树的根节点 root 和一个表示目标和的整数 targetSum 。判断该树中是否存在 根节点到叶子节点 的路径&#xff0c;这条路径上所有节点值相加等于目标和 target…

框架设计MVC

重点&#xff1a; 1.用户通过界面操作&#xff0c;传输到control&#xff0c;control可以直接去处理View&#xff0c;或者通过模型处理业务逻辑&#xff0c;然后将数据传输给view。 2.control包含了model和view成员。 链接&#xff1a; MVC框架详解_mvc架构-CSDN博客 MVC架…

vue 给特定满足条件的表单数据添加背景颜色,组件的 row-class-name

1、:row-class-name"tableRowClassName" 可为表格每行根据后面的函数绑定class名 <!-- 列表框 --><div class"tableList"><el-table :data"teamModelListTable" style"width: 100%"selection-change"handleSele…

【Sklearn-驯化】一文搞懂sklearn中特征平滑之-贝叶斯平滑策略使用技巧

【Sklearn-驯化】一文搞懂sklearn中特征平滑之-贝叶斯平滑策略使用技巧 本次修炼方法请往下查看 &#x1f308; 欢迎莅临我的个人主页 &#x1f448;这里是我工作、学习、实践 IT领域、真诚分享 踩坑集合&#xff0c;智慧小天地&#xff01; &#x1f387; 免费获取相关内容…

C++ std::lock_guard和 std::unique_lock

二者都是 C 标准库中用于管理互斥锁&#xff08;mutex&#xff09;的 RAII&#xff08;Resource Acquisition Is Initialization&#xff09;机制的类。这些类可以确保互斥锁在构造时被获取&#xff0c;在析构时被释放&#xff0c;从而避免死锁和资源泄漏问题。不过&#xff0c…

在SpringCloud中如何轻松实现微服务间的通信

在Spring Cloud中&#xff0c;实现微服务间的通信非常简单。Spring Cloud提供了多种方式来进行微服务之间的通信&#xff0c;包括使用RestTemplate、Feign、Ribbon、Eureka等组件。下面我将详细介绍这些方式的使用方法。 使用RestTemplate进行通信&#xff1a; RestTemplate是S…

MongoDB常用命令大全,概述、备份恢复

文章目录 一、MongoDB简介二、服务启动停止、连接三、数据库相关四、集合操作五、文档操作六、数据备份与恢复/导入导出数据6.1 mongodump备份数据库6.2 mongorestore还原数据库6.3 mongoexport导出表 或 表中部分字段6.4 mongoimport导入表 或 表中部分字段 七、其他常用命令八…

[笔记]Fluke3563 振动分析仪

参考文档&#xff1a;Fluke 3563 Analysis Vibration Sensor system | Fluke 1.四大机械故障损伤原因 2.振动特征 福禄克做的示意图很棒&#xff1a; 不平衡对应转动轴的一倍频&#xff0c;不对中是2倍频&#xff0c;然后3~6倍频会有未紧固故障&#xff0c;更高频的位置是齿轮…

全栈 Discord 克隆:Next.js 13、React、Socket.io、Prisma、Tailwind、MySQL笔记(一)

前言 阅读本文你需要有 Next.js 基础 React 基础 Prisma 基础 tailwind 基础 MySql基础 准备工作 打开网站 https://ui.shadcn.com/docs 这不是一个组件库。它是可重用组件的集合&#xff0c;您可以将其复制并粘贴到应用中。 打开installation 选择Next.js 也就是此页面…

JRebelXRebel在线激活(亲测可用)

包含所有新旧版本&#xff0c;包括2023.4.2、2023.4.1、2023.4.0、2023.3.2、2023.3.1、2023.3.0、2023.2.2、2023.2.1、2023.2.0、2023.1.2、2023.1.1 等以及所有2022版本 JRebel&XRebel激活服务器地址 激活服务器地址&#xff08;路线1,推荐&#xff09;&#xff0c;可…

鸿蒙语言基础类库:【@system.geolocation (地理位置)】

地理位置 说明&#xff1a; 从API Version 7 开始&#xff0c;该接口不再维护&#xff0c;推荐使用新接口[ohos.geolocation]。本模块首批接口从API version 3开始支持。后续版本的新增接口&#xff0c;采用上角标单独标记接口的起始版本。 导入模块 import geolocation from …