Open deby13 opened 3 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
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')
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')
cnn = tf.keras.models.Sequential()
cnn.add(tf.keras.layers.Conv2D(filters=32, kernel_size=3, activation='relu', input_shape=[64, 64, 3]))
cnn.add(tf.keras.layers.MaxPool2D(pool_size=2, strides=2))
cnn.add(tf.keras.layers.Conv2D(filters=32, kernel_size=3, activation='relu')) cnn.add(tf.keras.layers.MaxPool2D(pool_size=2, strides=2))
cnn.add(tf.keras.layers.Flatten())
cnn.add(tf.keras.layers.Dense(units=128, activation='relu'))
cnn.add(tf.keras.layers.Dense(units=4, activation='softmax'))
cnn.compile(optimizer = 'adam', loss = 'categorical_crossentropy', metrics = ['accuracy']) input("Any thing")
input(cnn.summary())
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.SelectEnumerableIterator
2.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.
board maixduino OS: Linus on Windows (WSL)
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
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