Make both networks output the same value types.

Both CIFAR and LENET work still.

The smile network... I couldn;t really get to work before or afterwards.
I noticed the Haar one has trouble finding my face. Maybe fix via using
the contrast settings of the previous Haar scripts?
This commit is contained in:
Kwabena W. Agyeman 2018-06-22 02:28:49 -04:00
parent 9a61a73711
commit f49576a679
4 changed files with 4 additions and 4 deletions

View File

@ -22,7 +22,7 @@ while(True):
img = sensor.snapshot() # Take a picture and return the image.
out = net.forward(img)
max_idx = out.index(max(out))
score = int(((out[max_idx]+128)/255)*100)
score = int(out[max_idx]*100)
if (score < 70):
score_str = "??:??%"
else:

View File

@ -32,6 +32,6 @@ while (True):
r = [r[0], r[1]+10, int(r[2]*1.1), int(r[2]*1.1)]
img.draw_rectangle(r)
out = net.forward(img, roi=r, softmax=True)
img.draw_string(r[0], r[1], ':)' if (out[0]/127 > 0.8) else ':(', color=(255), scale=2)
img.draw_string(r[0], r[1], ':)' if (out[0] > 0.8) else ':(', color=(255), scale=2)
print(clock.fps())

View File

@ -20,7 +20,7 @@ while(True):
img = sensor.snapshot() # Take a picture and return the image.
out = net.forward(img.copy().binary([(150, 255)], invert=True))
max_idx = out.index(max(out))
score = int(((out[max_idx]+128)/255)*100)
score = int(out[max_idx]*100)
if (score < 70):
score_str = "??:??%"
else:

View File

@ -50,7 +50,7 @@ STATIC mp_obj_t py_net_forward(uint n_args, const mp_obj_t *args, mp_map_t *kw_a
}
for (int i=0; i<net->output_size; i++) {
mp_obj_list_append(output_list, mp_obj_new_int(net->output_data[i]));
mp_obj_list_append(output_list, mp_obj_new_float(((float) (net->output_data[i] + 128)) / 255));
}
fb_alloc_free_till_mark();