Skip to content

Commit

Permalink
adding evaluation plots
Browse files Browse the repository at this point in the history
  • Loading branch information
workstation1 gpu committed May 29, 2022
1 parent cc8f334 commit d991728
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 23 deletions.
21 changes: 12 additions & 9 deletions cmvae/eval_cmvae.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import racing_utils
from racing_utils.paths import *
# DEFINE TESTING META PARAMETERS
data_dir = ppr_img_data_dir
data_dir = ws_eval_dir
read_table = True
latent_space_constraints = True
weights_path = ppr_cmvae_output_dir + "/cmvae_model_45.ckpt"
weights_path = ws_cmvae_250K_output_dir + "/cmvae_model_50.ckpt"

n_z = 10
img_res = 64
Expand All @@ -25,8 +25,8 @@
rows = 10

num_interp_z = 10
idx_close = 0 #7
idx_far = 1 #39
idx_close = 7 #7
idx_far = 44 #39

z_range_mural = [-0.02, 0.02]
z_num_mural = 11
Expand All @@ -44,9 +44,9 @@
images_np, raw_table = racing_utils.dataset_utils.create_test_dataset_csv(data_dir, img_res, read_table=read_table)
print('Done with dataset')

images_np = images_np[:1000,:]
if read_table is True:
raw_table = raw_table[:1000,:]
# images_np = images_np[:1000,:]
# if read_table is True:
# raw_table = raw_table[:1000,:]

# create model
if latent_space_constraints is True:
Expand Down Expand Up @@ -86,6 +86,7 @@
plt.axis('off')
plt.imshow(img_display)
# fig.savefig(os.path.join('D:/ppr_files/figs', 'reconstruction_results.png'))
plt.savefig("../figs/img_recon.png")
plt.show()

# show interpolation btw two images in latent space
Expand Down Expand Up @@ -134,7 +135,7 @@
axs[1].set_ylabel(r'[deg]')
axs[2].set_ylabel(r'[deg]')
axs[3].set_ylabel(r'[deg]')

plt.savefig('../figs/interpolation_graph.png')
# plot the interpolated images
fig2 = plt.figure(figsize=(96, 96))
columns = num_interp_z + 2
Expand All @@ -153,6 +154,7 @@
plt.axis('off')
plt.imshow(img_display)
# fig2.savefig(os.path.join('D:/ppr_files/figs', 'reconstruction_interpolation_results.png'))
plt.savefig("../figs/interpolated.png")
plt.show()

# new plot traveling through latent space
Expand All @@ -172,4 +174,5 @@
plt.axis('off')
plt.imshow(img_display)
# fig3.savefig(os.path.join('D:/ppr_files/figs', 'z_mural.png'))
plt.show()
plt.savefig("../figs/traveling_in_the_latent_space.png")
plt.show()
Binary file modified datagen/img_generator/__pycache__/pose_sampler.cpython-38.pyc
Binary file not shown.
18 changes: 9 additions & 9 deletions datagen/img_generator/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from time import sleep
from pose_sampler import *

num_samples = 50000
dataset_path = ws_img_data_250k_dir
num_samples = 1000
dataset_path = ws_eval_dir

# check if output folder exists
if not os.path.isdir(dataset_path):
Expand All @@ -11,13 +11,13 @@
os.makedirs(img_dir)
else:
print("Error: path already exists.")
# flag= input("Enter Y/y to confirm folder deletion and recreation or any letter to abort: ")
# if flag == 'y' or flag == 'Y' :
# shutil.rmtree(dataset_path)
# os.makedirs(dataset_path)
# img_dir = os.path.join(dataset_path, 'images')
# os.makedirs(img_dir)
# else: exit()
flag= input("Enter Y/y to confirm folder deletion and recreation or any letter to abort: ")
if flag == 'y' or flag == 'Y' :
shutil.rmtree(dataset_path)
os.makedirs(dataset_path)
img_dir = os.path.join(dataset_path, 'images')
os.makedirs(img_dir)
else: exit()

pose_sampler = PoseSampler(num_samples, dataset_path)

Expand Down
4 changes: 2 additions & 2 deletions datagen/img_generator/pose_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
UAV_PITCH_RANGE = [-eps, eps] #[-np.pi/4, np.pi/4]
UAV_ROLL_RANGE = [-eps, eps] #[-np.pi/4, np.pi/4]

R_RANGE = [6, 12] # in meters
R_RANGE = [2, 8] # in meters
correction = 0.85
CAM_FOV = 90.0*correction # in degrees -- needs to be a bit smaller than 90 in fact because of cone vs. square

Expand All @@ -42,7 +42,7 @@ def __init__(self, num_samples, dataset_path, with_gate=True):
self.num_samples = num_samples
self.base_path = dataset_path
self.csv_path = os.path.join(self.base_path, 'gate_training_data.csv')
self.curr_idx = 250000
self.curr_idx = 0
self.with_gate = with_gate
self.client = airsim.MultirotorClient()

Expand Down
Binary file added figs/error_density.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figs/img_recon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figs/interpolated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figs/interpolation_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figs/traveling_in_the_latent_space.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified racing_utils/__pycache__/paths.cpython-38.pyc
Binary file not shown.
Binary file modified racing_utils/__pycache__/stats_utils.cpython-38.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions racing_utils/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ws_cmvae_output_dir = "/home/dell/Drone_Project/models_outputs/cmvae_con"

ws_img_data_250k_dir = "/home/dell/Drone_Project/datasets/img_data_250K"
ws_eval_dir = "/home/dell/Drone_Project/datasets/evaluation_data"
ws_img_data_50k_dir = "/home/dell/Drone_Project/datasets/img_data_50K"
ws_cmvae_250K_output_dir = "/home/dell/Drone_Project/models_outputs/cmvae_con_250k"
ws_il_data_dir = "/home/dell/Drone_Project/datasets/il_data"
Expand Down
6 changes: 3 additions & 3 deletions racing_utils/stats_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def calculate_gate_stats(predictions, poses):
weights = np.ones(len(abs_diff[:, 0]))/len(abs_diff[:, 0])

axs[0].hist(abs_diff[:, 0], bins=30, range=(0,2.0), weights=weights, density=False)
axs[1].hist(abs_diff[:, 1]*180/np.pi, bins=30, range=(0, np.pi/20*180/np.pi), weights=weights, density=False)
axs[2].hist(abs_diff[:, 2]*180/np.pi, bins=30, range=(0, np.pi/20*180/np.pi), weights=weights, density=False)
axs[1].hist(abs_diff[:, 1]*180/np.pi, bins=50, range=(0, np.pi/20*180/np.pi), weights=weights, density=False)
axs[2].hist(abs_diff[:, 2]*180/np.pi, bins=50, range=(0, np.pi/20*180/np.pi), weights=weights, density=False)
axs[3].hist(abs_diff[:, 3]*180/np.pi, bins=50, range=(0, np.pi/4*180/np.pi), weights=weights, density=False)

for idx in range(4):
Expand All @@ -46,7 +46,7 @@ def calculate_gate_stats(predictions, poses):
# axs[3].set_xlabel(r'[$^{\circ}$]')

axs[0].set_ylabel('Error Density')

plt.savefig("../figs/error_density.png")
plt.show()

print('bla')
Expand Down

0 comments on commit d991728

Please sign in to comment.