def get(self, id): dataset_json = io.load_topviewkinect_dataset(id) labels_df = io.load_topviewkinect_labels(id) labels_series = labels_df.loc[:, "activity"] orientations_series = labels_df.loc[:, "orientation"] orientations_status_series = labels_df.loc[:, "orientation_accurate"] num_frames = len(labels_series.index) num_pages = int(math.ceil(num_frames / FRAME_PAGINATION_SIZE)) frame_labels = labels_series[:FRAME_PAGINATION_SIZE] frame_labels_dict = frame_labels.to_dict() frame_orientations = orientations_series[:FRAME_PAGINATION_SIZE] frame_orientations_dict = frame_orientations.to_dict() frame_orientations_status = orientations_status_series[: FRAME_PAGINATION_SIZE] frame_orientations_status_dict = frame_orientations_status.to_dict() self.render( "dataset.html", dataset=dataset_json, page_size=FRAME_PAGINATION_SIZE, num_pages=num_pages, page_num=1, frame_labels_dict=frame_labels_dict, frame_orientations_dict=frame_orientations_dict, frame_orientations_status_dict=frame_orientations_status_dict)
def get(self, id): dataset_json = io.load_topviewkinect_dataset(id) labels_df = io.load_topviewkinect_labels(id) labels_series = labels_df.loc[:, "activity"] orientations_series = labels_df.loc[:, "orientation"] orientations_status_series = labels_df.loc[:, "orientation_accurate"] num_frames = len(labels_series.index) num_pages = int(math.ceil(num_frames / FRAME_PAGINATION_SIZE)) frame_labels = labels_series[:FRAME_PAGINATION_SIZE] frame_labels_dict = frame_labels.to_dict() frame_orientations = orientations_series[:FRAME_PAGINATION_SIZE] frame_orientations_dict = frame_orientations.to_dict() frame_orientations_status = orientations_status_series[:FRAME_PAGINATION_SIZE] frame_orientations_status_dict = frame_orientations_status.to_dict() self.render("dataset.html", dataset=dataset_json, page_size=FRAME_PAGINATION_SIZE, num_pages=num_pages, page_num=1, frame_labels_dict=frame_labels_dict, frame_orientations_dict=frame_orientations_dict, frame_orientations_status_dict=frame_orientations_status_dict)
def get(self, id, size, page): labels_df = io.load_topviewkinect_labels(id) activities = labels_df.loc[:, "activity"] orientations = labels_df.loc[:, "orientation"] orientations_status = labels_df.loc[:, "orientation_accurate"] page_size = int(size) page_num = int(page) frame_ids_from = (page_num - 1) * page_size frame_ids_to = page_num * page_size frame_labels_dict = activities[frame_ids_from:frame_ids_to].to_dict() orientations_dict = orientations[frame_ids_from:frame_ids_to].to_dict() orientations_status_dict = orientations_status[ frame_ids_from:frame_ids_to].to_dict() # Dictionaries must be strings to be json encoded frame_labels_dict = dict( zip(list(map(str, frame_labels_dict.keys())), list(map(str, frame_labels_dict.values())))) frame_orientations_dict = dict( zip(list(map(str, orientations_dict.keys())), list(map(str, orientations_dict.values())))) frame_orientations_status_dict = dict( zip(list(map(str, orientations_status_dict.keys())), list(map(str, orientations_status_dict.values())))) # Note: Handle duplicate elements in list when there are multiple skeletons self.finish( tornado.escape.json_encode({ "frame_labels_dict": frame_labels_dict, "frame_orientations_dict": frame_orientations_dict, "frame_orientations_status_dict": frame_orientations_status_dict }))
def get(self, id, size, page): labels_df = io.load_topviewkinect_labels(id) activities = labels_df.loc[:, "activity"] orientations = labels_df.loc[:, "orientation"] orientations_status = labels_df.loc[:, "orientation_accurate"] page_size = int(size) page_num = int(page) frame_ids_from = (page_num - 1) * page_size frame_ids_to = page_num * page_size frame_labels_dict = activities[frame_ids_from:frame_ids_to].to_dict() orientations_dict = orientations[frame_ids_from:frame_ids_to].to_dict() orientations_status_dict = orientations_status[frame_ids_from:frame_ids_to].to_dict() # hack (dictionaries must be strings to be json encoded) frame_labels_dict = dict( zip(list(map(str, frame_labels_dict.keys())), list(map(str, frame_labels_dict.values()))) ) frame_orientations_dict = dict( zip(list(map(str, orientations_dict.keys())), list(map(str, orientations_dict.values()))) ) frame_orientations_status_dict = dict( zip(list(map(str, orientations_status_dict.keys())), list(map(str, orientations_status_dict.values()))) ) # for future self: there's a bug here # - duplicate elements in list when there are multiple skeletons self.finish(tornado.escape.json_encode({ "frame_labels_dict": frame_labels_dict, "frame_orientations_dict": frame_orientations_dict, "frame_orientations_status_dict": frame_orientations_status_dict }))