sipeed / MaixPy-v1

MicroPython for K210 RISC-V, let's play with edge AI easier
https://wiki.sipeed.com/maixpy
Other
1.68k stars 438 forks source link

Nullable object must have a value #438

Open deby13 opened 2 years ago

deby13 commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Actual behaviour Tell us what happens instead

Screenshots If applicable, add screenshots to help explain your problem.

Please complete the following information

deby13 commented 2 years ago

using instruction on the sipeed Blog to convert h5 to kmodel . using ./tflite2kmodel.sh workspace/Modelo.tflite

--- convolutional network

import tensorflow as tf from tensorflow.keras.preprocessing.image import ImageDataGenerator from tensorflow.keras.models import load_model import PIL from PIL import Image tf.version

Part 1 - Data Preprocessing

Preprocessing the Training set

train_datagen = ImageDataGenerator(rescale = 1./255, shear_range = 0.2, zoom_range = 0.2, horizontal_flip = True) training_set = train_datagen.flow_from_directory('dataset/training_set', target_size = (64, 64), batch_size = 32, class_mode = 'categorical')

Preprocessing the Test set

test_datagen = ImageDataGenerator(rescale = 1./255) test_set = test_datagen.flow_from_directory('dataset/test_set', target_size = (64, 64), batch_size = 32, class_mode = 'categorical')

Part 2 - Building the CNN

Initialising the CNN

cnn = tf.keras.models.Sequential()

Step 1 - Convolution

cnn.add(tf.keras.layers.Conv2D(filters=32, kernel_size=3, activation='relu', input_shape=[64, 64, 3]))

Step 2 - Pooling

cnn.add(tf.keras.layers.MaxPool2D(pool_size=2, strides=2))

Adding a second convolutional layer

cnn.add(tf.keras.layers.Conv2D(filters=32, kernel_size=3, activation='relu')) cnn.add(tf.keras.layers.MaxPool2D(pool_size=2, strides=2))

Step 3 - Flattening

cnn.add(tf.keras.layers.Flatten())

Step 4 - Full Connection

cnn.add(tf.keras.layers.Dense(units=128, activation='relu'))

Step 5 - Output Layer

cnn.add(tf.keras.layers.Dense(units=4, activation='softmax'))

Part 3 - Training the CNN

Compiling the CNN

cnn.compile(optimizer = 'adam', loss = 'categorical_crossentropy', metrics = ['accuracy']) input("Any thing")

input(cnn.summary())

Training the CNN on the Training set and evaluating it on the Test set

cnn.fit(x = training_set, validation_data = test_set, epochs = 2)

cnn.save("modeloP36")

the result modeloP36 was copied to workspace in the Max_toolbox_master

expected to get file converted

intead got the error error: NNcase : trying to convert tfile to kmodel

screenshot uasge: ./tflite2kmodel.sh xxx.tflite Fatal: Nullable object must have a value. System.InvalidOperationException: Nullable object must have a value. at System.Nullable1.get_Value() at NnCase.Converter.Converters.TfLiteToGraphConverter.ConvertReshape(Operator op) in D:\Work\Repository\nncase\src\NnCase.Converter\Converters\TfLiteToGraphConverter.cs:line 197 at NnCase.Converter.Converters.TfLiteToGraphConverter.ConvertOperator(Operator op) in D:\Work\Repository\nncase\src\NnCase.Converter\Converters\TfLiteToGraphConverter.cs:line 97 at System.Linq.Enumerable.SelectEnumerableIterator2.ToList() at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at NnCase.Converter.Converters.TfLiteToGraphConverter.Convert() in D:\Work\Repository\nncase\src\NnCase.Converter\Converters\TfLiteToGraphConverter.cs:line 34 at NnCase.Cli.Program.Main(String[] args) in D:\Work\Repository\nncase\src\NnCase.Cli\Program.cs:line 113 at NnCase.Cli.Program.

(String[] args)

board maixduino OS: Linus on Windows (WSL)