示例#1
0
direct_frames = []
for t in range(0 + hist, n_test - 1):
    z_new = z_test[t].copy()
    z_new_test = z_test[t].copy()
    x_new = x_test[t].copy()
    x_hat_pf = pf.step(z_new)
    plt.subplot(1, 2, 1)
    plt.imshow(x_hat_pf)
    plt.subplot(1, 2, 2)
    plt.imshow(x_new)
    plt.show()
    # cv2.imshow("real",normalize_image(x_new))
    # cv2.imshow("pf",normalize_image(x_hat_pf))
    # if cv2.waitKey(1) & 0xFF == ord('q'):
    #     break
    obs_frames.append(add_border(normalize_image(z_new)))
    state_frames.append(add_border(normalize_image(x_new)))
    pf_frames.append(add_border(normalize_image(x_hat_pf)))
# cv2.destroyAllWindows()

# ---- Saves multiple samples as an image ---- #
idxs = np.arange(15, 55, 4, dtype=np.int16)
obs_img = np.concatenate(tuple(np.array(obs_frames)[idxs]), axis=1)
state_img = np.concatenate(tuple(np.array(state_frames)[idxs]), axis=1)
pf_img = np.concatenate(tuple(np.array(pf_frames)[idxs]), axis=1)
full_img = np.concatenate((obs_img, state_img, df_img),
                          axis=0).astype(np.uint8)
matplotlib.image.imsave('samples_pf.png', full_img, cmap='gray')

# ---- Saves a video ---- #
outputdata = np.array(frames).astype(np.uint8)
示例#2
0
    cm_err_df.append(cm_error(x_new, x_hat_df))
    mass_err_df.append(mass_error(x_new, x_hat_df))
    img_err_df.append(img_desc(x_new, x_hat_df))
    img_kl_df.append(KL_img(x_new, x_hat_df))

    cm_err_pf.append(cm_error(x_new, x_hat_pf))
    mass_err_pf.append(mass_error(x_new, x_hat_pf))
    img_err_pf.append(img_desc(x_new, x_hat_pf))
    img_kl_pf.append(KL_img(x_new, x_hat_pf))

    cm_err_direct.append(cm_error(x_new, x_hat_df_like))
    mass_err_direct.append(mass_error(x_new, x_hat_df_like))
    img_err_direct.append(img_desc(x_new, x_hat_df_like))
    img_kl_direct.append(KL_img(x_new, x_hat_df_like))

    pf_frames.append(add_border(normalize_image(x_hat_pf)))
    obs_frames.append(add_border(normalize_image(z_new)))
    state_frames.append(add_border(normalize_image(x_new)))
    df_frames.append(add_border(normalize_image(x_hat_df)))
    direct_frames.append(add_border(normalize_image(x_hat_df_like)))

    frame1 = np.concatenate(
        (normalize_image(x_new), normalize_image(z_new), np.zeros_like(z_new)),
        axis=1)
    frame2 = np.concatenate(
        (normalize_image(x_hat_df), normalize_image(x_hat_df_like),
         normalize_image(x_hat_pf)),
        axis=1)
    frame = np.concatenate((frame1, frame2), axis=0)
    frames.append(frame)
示例#3
0
x_old = x_test[0:hist, ...].copy()

for t in range(0 + hist, n_test - 1):
    z_new = z_test[t].copy()
    z_new_test = z_test[t].copy()
    x_new = x_test[t].copy()
    #x_hat_pf = pf.step(z_new)
    x_hat_df = df.predict_mean(x_old, z_new)
    x_hat_df = x_hat_df[:, :, 0]
    #x_hat_df[x_hat_df<0.5] = 0
    x_hat_df_like = df.estimate(z_new_test)
    x_hat_df_like = x_hat_df_like[0, :, :, 0]
    #x_hat_df_like[x_hat_df_like<0.5] = 0
    x_old[:-1, :, :] = x_old[1:, :, :]
    x_old[-1, :, :] = x_hat_df
    obs_frames.append(add_border(normalize_image(z_new)))
    state_frames.append(add_border(normalize_image(x_new)))
    df_frames.append(add_border(normalize_image(x_hat_df)))
    direct_frames.append(add_border(normalize_image(x_hat_df_like)))
    frame1 = np.concatenate((normalize_image(x_new), normalize_image(z_new)),
                            axis=1)
    frame2 = np.concatenate(
        (normalize_image(x_hat_df), normalize_image(x_hat_df_like)), axis=1)
    frame = np.concatenate((frame1, frame2), axis=0)
    frames.append(frame)

# ---- Saves multiple samples as an image ---- #
idxs = np.arange(0, 200, 5, dtype=np.int16)
obs_img = np.concatenate(tuple(np.array(obs_frames)[idxs]), axis=1)
state_img = np.concatenate(tuple(np.array(state_frames)[idxs]), axis=1)
df_img = np.concatenate(tuple(np.array(df_frames)[idxs]), axis=1)