Пример #1
0
  grey_sprite.draw()
  sobel_sprite.draw()
  hog_sprite.draw()
  hidden_sprite.draw()
  for st in str_list:
    st.draw()
  arrow.draw()

  k = mykeys.read()
  if k >-1:
    if k == 27:
      mykeys.close()
      DISPLAY.destroy()
      break
    elif k == ord(' '):
      im = np.array(Image.open(random.choice(flist)))
      outlayer = mlp.feed_forward(ip.get_hog(im))
      grey_tex.update_ndarray(false_colour(ip.grey_scale))
      sobel_tex.update_ndarray(false_colour(ip.edges))
      hog_tex.update_ndarray(false_colour(ip.hog.reshape(16, 128)))
      hidden_tex.update_ndarray(false_colour(mlp.ah.reshape(8, 8)))
      arrow.positionY(1.0 - 0.5 * outlayer.argmax())
      str_colours = false_colour(outlayer.reshape(5,1)) / 255.0
      for i, st in enumerate(str_list):
        st.set_material(str_colours[i, 0])
    elif k == ord('p'):
      pi3d.screenshot("/home/patrick/Downloads/scr_caps_pi3d/scr_caps/fr{:03d}.jpg".format(fr))
      fr += 1

    grey_sprite.draw()
    sobel_sprite.draw()
    hog_sprite.draw()
    hidden_sprite.draw()
    for st in str_list:
        st.draw()
    arrow.draw()

    k = mykeys.read()
    if k > -1:
        if k == 27:
            mykeys.close()
            DISPLAY.destroy()
            break
        elif k == ord(' '):
            im = np.array(Image.open(random.choice(flist)))
            outlayer = mlp.feed_forward(ip.get_hog(im))
            grey_tex.update_ndarray(false_colour(ip.grey_scale))
            sobel_tex.update_ndarray(false_colour(ip.edges))
            hog_tex.update_ndarray(false_colour(ip.hog.reshape(16, 128)))
            hidden_tex.update_ndarray(false_colour(mlp.ah.reshape(8, 8)))
            arrow.positionY(1.0 - 0.5 * outlayer.argmax())
            str_colours = false_colour(outlayer.reshape(5, 1)) / 255.0
            for i, st in enumerate(str_list):
                st.set_material(str_colours[i, 0])
        elif k == ord('p'):
            pi3d.screenshot(
                "/home/patrick/Downloads/scr_caps_pi3d/scr_caps/fr{:03d}.jpg".
                format(fr))
            fr += 1