def __init__(self, resume_checkpoint='utilities/obman_train/release_models/obman/checkpoint.pth.tar', mano_root='utilities/obman_train/misc/mano', no_beta=True,cache_loc='cache/hand_mesh', image_extension='.jpg', overwrite=False ): self.overwrite = overwrite self.extension_length = len(image_extension) self.cache_loc = cache_loc if not os.path.exists(self.cache_loc): os.makedirs(self.cache_loc, exist_ok=True) self.resume = resume_checkpoint self.checkpoint = os.path.dirname(self.resume) with open(os.path.join(self.checkpoint, 'opt.pkl'), 'rb') as opt_f: self.opts = pickle.load(opt_f) self.no_beta = no_beta self.mano_root = mano_root self.model = reload_model(self.resume, self.opts, mano_root=self.mano_root, no_beta=self.no_beta) self.model.eval()
"--image_path", help="Path to image", default="readme_assets/images/can.jpg", ) parser.add_argument("--no_beta", action="store_true", help="Force shape to average") args = parser.parse_args() argutils.print_args(args) checkpoint = os.path.dirname(args.resume) with open(os.path.join(checkpoint, "opt.pkl"), "rb") as opt_f: opts = pickle.load(opt_f) # Initialize network model = reload_model(args.resume, opts, no_beta=args.no_beta) model.eval() print("Input image is processed flipped and unflipped " "(as left and right hand), both outputs are displayed") # load faces of hand with open("misc/mano/MANO_RIGHT.pkl", "rb") as p_f: mano_right_data = pickle.load(p_f, encoding="latin1") faces = mano_right_data["f"] fig = plt.figure(figsize=(4, 4)) fig.clf() frame = cv2.imread(args.image_path) frame = preprocess_frame(frame)