Ahh yes! thanks for the thoughtful suggestion.
However, I already tried binarizing the input feed and the output is generating same result (say any particular number for e.g. ‘five’) no matter what the feed is.
Here’s the code that I used:
import sensor, image, time, os, tf
sensor.reset() # Reset and initialize the sensor.
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((128, 128)) # Set 128x128 window.
net = tf.load('/mnistconv_int8.tflite')
labels = ["zero","one","two","three","four","five","six","seven","eight","nine"]
clock = time.clock()
img = sensor.snapshot()
out = net.classify(img.copy().binary([( 0, 1)], invert=True))
score = max(out) * 100
max_idx = out.index(max(out))
if (score < 50):
score_str = "??:??%"
score_str = "%s:%d%% "%(labels[max_idx], score)
img.draw_string(0, 0, score_str)
I also tried using other model files without changing the train code, but the same behavior continues at output with another number getting fixed as the new output.
So basically, the output changes with change of model files but is constant for a particular model with a slight variation in scores here & there.
Let me know if the code needs some modifications or any other suggestions.
Thanks & Regards,