Hello,
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_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((128, 128)) # Set 128x128 window.
sensor.skip_frames(time=100)
sensor.set_auto_gain(False)
sensor.set_auto_exposure(False)
net = tf.load('/mnistconv_int8.tflite')
labels = ["zero","one","two","three","four","five","six","seven","eight","nine"]
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
out = net.classify(img.copy().binary([( 0, 1)], invert=True))
score = max(out[0][4]) * 100
max_idx = out[0][4].index(max(out[0][4]))
if (score < 50):
score_str = "??:??%"
else:
score_str = "%s:%d%% "%(labels[max_idx], score)
img.draw_string(0, 0, score_str)
print(clock.fps())
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,
IM