If you softmax the output. Our code doesn’t do that for you. We just get 0-255 out from the library and then we divide that by 255 and then that’s the float result.
Can you attach the trained model for me to run, along with 1 or two images? Thanks,
If you softmax the output. Our code doesn’t do that for you. We just get 0-255 out from the library and then we divide that by 255 and then that’s the float result.
Can you attach the trained model for me to run, along with 1 or two images? Thanks,
Yes, Thank you.
I don’t know how to create a white image with 28x28x1 by code(like np.ones()*255)
(if any code could make it , please let me know)
so i read a white.ppm from flash.
I already check they are exactly 255 value every pixels.
I attached the models and a white image
the code as below
sensor.set_contrast(3)
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
sensor.set_windowing((28, 28)) # Set 128x128 window.
sensor.skip_frames(time=100)
sensor.set_auto_gain(False)
sensor.set_auto_exposure(False)
net = tf.load('/mnist_model_quant_io.tflite')
clock = time.clock()
while (True):
clock.tick()
myImage = image.Image("white.ppm", copy_to_fb = True)
graytmp = myImage.to_grayscale(True, rgb_channel=0)
#print('graytmp',graytmp)
#for y in range(0, 28):
#str_value = ''
#for x in range(0, 28):
#str_value += str(graytmp.get_pixel(x,y))+' '
#print(str_value)
#print('-------------')
out = net.classify(graytmp)
print(out)
model and white ppm.7z (17.3 KB)
Hi, I was able to run your model.
The model gets the correct result. But, the TensorFlow vector output is not the same.
RAW Output = [0.5019608, 0.5019608, 0.5369792, 0.9202359, 0.5019608, 0.544761, 0.5019608, 0.5019608, 0.5019608, 0.5019608]
After SoftMax = [0.09435112, 0.09435112, 0.09771368, 0.1433513, 0.09435112, 0.09847704, 0.09435112, 0.09435112, 0.09435112, 0.09435112] → Sums to 1.0
If we look at your result: [0. 0. 0.0625 0.8515625 0. 0.078125 0. 0. 0. 0. ]
Then compare to the original output:
0.5019608 * 255 == 128 → Which is 0 in Int8 math. /= 128 → 0
0.5369792 * 255 == 136 → Which is 8.9 in Int8 math. /= 128 → 0.06953125
0.9202359 * 255 == 234 → Which is 106 in Int8 math. /= 128 → 0.828125
0.544761 * 255 == 138 → Which is 10 in Int8 math. /= 128 → 0.078125
We can then see the result closely matches. However, there is an issue with the scaling input and output logic in our code.
It’s not been clear with TensorFlow what the input and output scales are… so, thanks for testing the code out. I should be able to fix my code to make this right. Everyone I ask at Google literally gives a different answer for what the network input and outputs should be in when using float/int8/uint8. It’s quite confusing.
New H7 Firmware.
firmware.zip (1.18 MB)
Thanks. The new firmware output the right vector values.
Hi,
I tested the updated firmware for both gray-scale & color images using the MNIST & CIFAR10 datasets respectively & finally they both work great (However CIFAR10 model was bit less accurate to keep the model size within limits of H7 but it worked well too). Thanks a tonne!
However, I wonder if Object Detection (with bounding boxes & respective labels on top of the boundin boxes) is possible or not in OpenMV cam yet?
If not, will we get to see such a functionality in near future?
Regards
It’s not happening yet. But, it probably will. Having a platform where folks can actually try out such a small network will spur development.
I’m about to release a new version of the IDE with some really nice features for deep learning and edge impulse integration support.
Image classification is probably the best we’ll see on the H7 silicon. Future chips will have much higher performance for object localization.
Um, if you know how to train a bounding box network that can fit within RAM on the H7 Plus then I can add code to handle the network output type.
Ahh, thanks for the clarification, &
Sure, I will train an object detection network too. For now you can try this object detection model trained on coco dataset. Its size is 4.2MB so I think it will do the job.
detect.zip (2.78 MB)
Hi, how do you map the output to bounding boxes?
Like, I understand what to do with image segmentation and classification outputs. I don’t know how to handle bounding box ones.