print(tf.__version__)
model = Sequential()
model.add(Conv2D(32, (5, 5), activation='relu', input_shape=(96, 96, 2)))
model.add(MaxPooling2D((2, 2)))
model.add(Dropout(0.2))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D((2, 2)))
model.add(Dropout(0.2))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D((2, 2)))
model.add(Dropout(0.2))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D((2, 2)))
model.add(Dropout(0.2))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D((2, 2)))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dense(64, activation='relu'))
model.add(Dense(32, activation='relu'))
model.add(Dense(2, activation='softmax'))
model.compile(optimizer='adam',loss='sparse_categorical_crossentropy',metrics=['accuracy'])
model.summary()
history=model.fit(X_train, y_train, epochs=100, batch_size=64, verbose=1, validation_data=(X_test, y_test))
这是我在python中部署的模型通过官方提供的工具生成了C语言的文件移植进程序后进行了下述代码的编写
以下是部分代码片段照片的大小是96*96 RGB565 板子ESP32-S3-EYE
int input_height = 96;
int input_width = 96;
int input_channel = 2;
int input_exponent = -7;
int16_t *model_input = (int16_t *)dl::tool::malloc_aligned_prefer(input_height*input_width*input_channel, sizeof(int16_t *));
camera_fb_t *fbd = NULL;
static const char *TAG = "example";
static void Get(void *){
while(1){
if (xSemaphoreTake(xMutexInventory, SPINLOCK_WAIT_FOREVER) == pdPASS){
fbd = esp_camera_fb_get();
ESP_LOGI("esp", "Len:%d Wid:%d High:%d \n",fbd->len,fbd->width,fbd->height);
for (int i = 0; i < fbd->len; i ++)
{
// fbd->buf=255-fbd->buf;
// if(fbd->buf<200)fbd->buf=0;
model_input=(int16_t)fbd->buf;
//printf("%d,",fbd->buf);
}
// vTaskDelay(500 / portTICK_PERIOD_MS);
Tensor<int16_t> input;
//input.set_element((int16_t *)fb->buf).set_exponent(input_exponent).set_shape({input_height,input_width,input_channel}).set_auto_free(false);
input.set_element((int16_t *)model_input).set_exponent(input_exponent).set_shape({input_height,input_width,input_channel}).set_auto_free(false);
HANDRECOGNITION model;
dl::tool::Latency latency;
latency.start();
model.forward(input);
latency.end();
latency.print("\nSIGN", "forward");
但是程序运行时代码报错为
assert failed: dl::Tensor<T>& dl::Tensor<T>::reshape(std::vector<int>) [with T = short int] dl_variable.cpp:77 (size == size_gt)
Backtrace: 0x403760c6:0x3fceb880 0x4037c691:0x3fceb8a0 0x40382795:0x3fceb8c0 0x4201743b:0x3fceb9e0 0x4200ce76:0x3fceba10 0x42017d82:0x3fcebab0 0x4200b869:0x3fcebad0 0x4037f325:0x3fcebf20
希望有一位好心的大佬帮我答疑解惑一下 非常感谢!!
在使用ESP-DL的时候遇到了麻烦 渴望获得大佬的解惑
Re: 在使用ESP-DL的时候遇到了麻烦 渴望获得大佬的解惑
reshape前后输入的size是不是有问题
Who is online
Users browsing this forum: No registered users and 46 guests