MCPcopy Create free account
hub / github.com/UVA-Computer-Vision-Lab/FrameINO / INO_Traj_evaluation

Function INO_Traj_evaluation

evaluation/evaluate_INO_Traj.py:68–225  ·  view source on GitHub ↗

Args: region_target_height (int): Height without the padding, the padding will be scaled together region_target_width (int): Width without the padding, the padding will be scaled together test_num_frames (int): Sampled number of frames from the G

(data_parent_path, region_target_height, region_target_width, test_num_frames)

Source from the content-addressed store, hash-verified

66
67
68def INO_Traj_evaluation(data_parent_path, region_target_height, region_target_width, test_num_frames):
69 '''
70 Args:
71 region_target_height (int): Height without the padding, the padding will be scaled together
72 region_target_width (int): Width without the padding, the padding will be scaled together
73 test_num_frames (int): Sampled number of frames from the GT and GEN generated results
74
75 '''
76
77 # Init the Co-Tracker Model (Offline mode)
78 device = "cuda"
79 cotracker = torch.hub.load("facebookresearch/co-tracker", "cotracker3_offline").to(device)
80
81
82
83 # Calculate the MAX nubmer of frames in video folder
84 total_gen_num_frames_one_video, total_gt_num_frames_one_video = 0, 0
85 for file_name in sorted(os.listdir(os.path.join(data_parent_path, "instance0"))):
86 if file_name.find("gen_frame") != - 1:
87 total_gen_num_frames_one_video += 1
88
89 if file_name.find("gt_frame") != - 1:
90 total_gt_num_frames_one_video += 1
91 print("We have total gen and gt number in one video of frames of ", total_gen_num_frames_one_video, total_gt_num_frames_one_video)
92
93
94 # Get the index
95 gen_indices = np.linspace(0, total_gen_num_frames_one_video - 1, test_num_frames, dtype=int)
96 gt_indices = np.linspace(0, total_gt_num_frames_one_video - 1, test_num_frames, dtype=int)
97 assert(len(gen_indices) == test_num_frames)
98 assert(len(gt_indices) == test_num_frames)
99
100
101
102 # Iterate each sub folder
103 all_video_score = []
104 start_time = time.time()
105 for instance_idx in range(len(os.listdir(data_parent_path))):
106
107
108 # Define the path
109 sub_folder_path = os.path.join(data_parent_path, "instance"+str(instance_idx))
110
111
112 # Read the Important information from processed_meta_data store inside the folder
113 processed_meta_data_store_path = os.path.join(sub_folder_path, "processed_meta_data.pkl")
114 assert(os.path.exists(processed_meta_data_store_path))
115 with open(processed_meta_data_store_path, 'rb') as file:
116 processed_meta_data = pickle.load(file)
117
118 # Fetch information
119 GT_track_traj = processed_meta_data["full_pred_tracks"]
120 original_height = int(processed_meta_data["original_height"])
121 original_width = int(processed_meta_data["original_width"])
122 resized_mask_region_box = processed_meta_data["resized_mask_region_box"]
123
124 # Read sample
125 sample_GT_frame = cv2.imread(os.path.join(sub_folder_path, "gt_padded_frame0.png"))

Callers 1

mass_evaluationFunction · 0.90

Calls 3

euclidean_distanceFunction · 0.85
timeMethod · 0.80
toMethod · 0.45

Tested by

no test coverage detected