n_train = n - n_test # ---- Get the dataset ---- # x, z = generate_dataset(img_shape, n=n, image_path=spo_dataset.__path__[0] + '/source_image/illusion.jpg') x_test = x[:n_train] z_test = z[:n_train] x_train = x[n_train:] z_train = z[n_train:] # ---- Initialize ---- # tf.keras.backend.clear_session() df = DeepNoisyBayesianFilter(hist, img_shape) # ---- Load weights ---- # df.load_weights('model_weights_illusion') # ---- initialize particle filter ---- # image_path = spo_dataset.__path__[0] + '/source_image/illusion.jpg' ref_img = cv2.imread(image_path, 0) ref_img = cv2.resize(ref_img, img_shape, interpolation=cv2.INTER_AREA) # %% pf = ParticleFilter_deep(Np=10000, No=2, ref_img=ref_img, radiuses=[18, 22], initial_pose=[[14, 18], [108, 104]],
# ---- initialize parameters ---- # hist = 4 img_shape = (128,128) noise_rate = 0.2 n = 600 n_test = 300 n_train = n - n_test # ---- Get the dataset ---- # # ---- initialize particle filter ---- # ref_img = np.array(data.checkerboard()).astype(np.float64) ref_img = cv2.resize(ref_img, img_shape,interpolation = cv2.INTER_AREA) tf.keras.backend.clear_session() df = DeepNoisyBayesianFilter(hist,img_shape) # ---- Load weights ---- # df.load_weights('model_weights_partially_observed_chekkers') pf = ParticleFilter_deep(Np = 100, No = 1, ref_img = ref_img, radiuses = [18], initial_pose = [[20,10]], beta = 60, likelihood=df) # ---- Get the dataset ---- # x, z = generate_dataset(img_shape = img_shape,
img_shape = (128, 128) noise_rate = 0.2 n = 600 n_test = 300 n_train = n - n_test # ---- Get the dataset ---- # x, z = generate_dataset(img_shape, n=n, image_type="checkers") x_test = x[:n_train] z_test = z[:n_train] x_train = x[n_train:] z_train = z[n_train:] # ---- Initialize ---- # tf.keras.backend.clear_session() df = DeepNoisyBayesianFilter(hist, img_shape) # ---- Train ---- # train_likelihood(df, x_train, z_train, epochs=130) #100 train_predictor(df, x_train, epochs=10, min_img=2) #5 train_predictor(df, x_train, epochs=15, min_img=20) #10 train_update(df, x_train, z_train, epochs=10, min_img=2) #10 train_relax(df, x_train, z_train, epochs=5, min_img=10) # 10 train_relax(df, x_train, z_train, epochs=50, min_img=50) # 10 train_relax(df, x_train, z_train, epochs=50, min_img=None) # 10 # ---- Test and viualize ---- # x_old = x_test[:hist, ...].copy() frames = [] obs_frames = []
x, z = generate_dataset( img_shape, n=n, image_path=spo_dataset.__path__[0] + '/source_image/tree.jpg', mask=spo_dataset.__path__[0] + '/source_image/tree_masked.jpg', partial=True) x_test = x[:n_train] z_test = z[:n_train] x_train = x[n_train:] z_train = z[n_train:] # ---- Initialize DF ---- # tf.keras.backend.clear_session() df = DeepNoisyBayesianFilter(hist, img_shape) # ---- Load weights ---- # df.load_weights('model_weights_partially_observed_tree') # ---- Initialize testing arrays ---- # # ---- initialize particle filter ---- # image_path = spo_dataset.__path__[0] + '/source_image/tree.jpg' ref_img = cv2.imread(image_path, 0) ref_img = cv2.resize(ref_img, img_shape, interpolation=cv2.INTER_AREA) pf = ParticleFilter_deep(Np=5000, No=1, ref_img=ref_img, radiuses=[20],
# ---- Get the dataset ---- # x, z = get_dataset_rotating_objects(image_shape=img_shape, n=n, var=0.5, Ber=True, partial=True) x_test = np.array(x[:n_test]) z_test = np.array(z[:n_test]) x_train = np.array(x[n_test:]) z_train = np.array(z[n_test:]) # ---- Initialize ---- # tf.keras.backend.clear_session() df = DeepNoisyBayesianFilter(hist, img_shape) # ---- Train ---- # train_likelihood(df, x_train, z_train, epochs=130) #100 train_predictor(df, x_train, epochs=20, min_img=2) #5 train_predictor(df, x_train, epochs=30, min_img=20) #10 train_update(df, x_train, z_train, epochs=10, min_img=2) #10 train_relax(df, x_train, z_train, epochs=5, min_img=10) # 10 train_relax(df, x_train, z_train, epochs=50, min_img=50) # 10 train_relax(df, x_train, z_train, epochs=200, min_img=None) # 10 # ---- Initialize testing arrays ---- # cm_err_df = [] mass_err_df = [] img_err_df = []