def pose2d_estimation(self): parser = ArgParse.create_parser() args, _ = parser.parse_known_args() args.checkpoint = False args.unlabeled = self.folder args.resume = config["resume"] args.stacks = config["num_stacks"] args.test_batch = config["batch_size"] args.img_res = [ config["heatmap_shape"][0] * 4, config["heatmap_shape"][1] * 4 ] args.hm_res = config["heatmap_shape"] args.num_classes = config["num_predict"] args.max_img_id = self.state.num_images - 1 # run the main, it will save the heatmaps and predictions in the image folder _, _ = pose2d_main(args) # makes sure cameras use the latest heatmaps and predictions self.set_cameras() self.set_mode(Mode.POSE) for ip in self.image_pose_list: ip.cam = self.camNetAll[ip.cam.cam_id] for ip in self.image_pose_list_bot: ip.cam = self.camNetAll[ip.cam.cam_id]
def pose2d_estimation(self): from deepfly.pose2d import ArgParse from deepfly.pose2d.drosophila import main parser = ArgParse.create_parser() args, _ = parser.parse_known_args() args.checkpoint = False args.unlabeled = self.folder args.resume = config["resume"] args.stacks = config["num_stacks"] args.test_batch = config["batch_size"] args.img_res = [ config["heatmap_shape"][0] * 4, config["heatmap_shape"][1] * 4 ] args.hm_res = config["heatmap_shape"] args.num_classes = config["num_predict"] args.max_img_id = self.state.num_images - 1 # run the main, it will save the heatmaps and predictions in the image folder _, _ = main(args) # makes sure cameras use the latest heatmaps and predictions self.set_cameras() self.camNet = self.camNetLeft self.set_mode(Mode.POSE) self.set_view(self.state.view) self.update_frame()
def pose2d_estimation(self, overwrite=True): """Runs the pose2d estimation on self.input_folder. Parameters: overwrite: whether to overwrite existing pose estimation results (default: True) """ parser = ArgParse.create_parser() args, _ = parser.parse_known_args() args.checkpoint = False args.unlabeled = self.input_folder args.output_folder = self.output_subfolder args.resume = config["resume"] args.stacks = config["num_stacks"] args.test_batch = config["batch_size"] args.img_res = [ config["heatmap_shape"][0] * 4, config["heatmap_shape"][1] * 4 ] args.hm_res = config["heatmap_shape"] args.num_classes = config["num_predict"] args.max_img_id = self.max_img_id args.overwrite = overwrite pose2d_main(args) # will write output files in output directory self.set_cameras( ) # makes sure cameras use the latest heatmaps and predictions
def parse_cli_args(): parser = argparse.ArgumentParser( description = "DeepFly3D pose estimation" ) parser.add_argument( "input_folder", help="Folder containing unlabeled images." ) parser.add_argument( "-n", "--num-images-max", help="Maximal number of images to process.", default=math.inf, type=int ) parser = ArgParse.add_arguments(parser) return parser.parse_args()
def pose2d_estimation(self): # print('begain pose2d estimation','\n') parser = ArgParse.create_parser() args, _ = parser.parse_known_args() # print(args, '\n pose2d_estimation') args.checkpoint = False args.unlabeled = self.folder # args.resume = config["resume"] # print(args.resume,'\nresume\n') args.resume = '../../weights/sh8_mpii.tar' args.stacks = config["num_stacks"] args.test_batch = config["batch_size"] args.img_res = [config["heatmap_shape"][0] * 4, config["heatmap_shape"][1] * 4] args.hm_res = config["heatmap_shape"] args.num_classes = config["num_predict"] args.max_img_id = self.state.num_images - 1 print('self.state.num_images', self.state.num_images) # run the main, it will save the heatmaps and predictions in the image folder args.train_joints = np.arange(args.num_classes) acc_joints_tmp = [] for i in range(3): p = [(i * 5) + k for k in args.acc_joints] acc_joints_tmp.extend(p) args.acc_joints = acc_joints_tmp # print(args.acc_joints, '^'*100) #TODO args.num_images_max = 2 args.workers = 2 # args.checkpoint = os.path.join(args.checkpoint, get_time()) # , # "_{}_{}_{}_{}_{}_{}_{}".format( # "predict" if args.unlabeled else "training", # args.arch, # args.stacks, # args.img_res, # args.blocks, # "mv" if args.multiview else "", # "temp" if args.multiview else "", # args.name, # ), # ) # args.checkpoint = ( # args.checkpoint.replace(" ", "_").replace("(", "_").replace(")", "_") # ) # args.checkpoint = args.checkpoint.replace("__", "_").replace("--", "-") # # getLogger('df3d').debug("Checkpoint dir: {}".format(args.checkpoint)) # args.checkpoint_image_dir = os.path.join(args.checkpoint, "./images/") # create checkpoint dir and image dir # if args.unlabeled is None: # if not isdir(args.checkpoint): # mkdir_p(args.checkpoint) # if not isdir(args.checkpoint_image_dir): # mkdir_p(args.checkpoint_image_dir) # if args.carry and not isdir( # os.path.join(args.annotation_path, args.unlabeled + "_network") # ): # mkdir_p(os.path.join(args.annotation_path, args.unlabeled + "_network")) # if args.carry and not isdir( # os.path.join(args.data_folder, args.unlabeled + "_network") # ): # mkdir_p(os.path.join(args.data_folder, args.unlabeled + "_network")) # print(args, '\npose2d_estimation(self)') _, _ = pose2d_main(args) # print('pose2d_main(args)', '$' * 70) # makes sure cameras use the latest heatmaps and predictions self.set_cameras() self.set_mode(Mode.POSE) # print('self.set_mode(Mode.POSE)', '$'*70) for ip in self.image_pose_list: ip.cam = self.camNetAll[ip.cam.cam_id] for ip in self.image_pose_list_bot: ip.cam = self.camNetAll[ip.cam.cam_id] self.update_frame()