def extract(self, image):
    image = image.astype(np.float32)
    size = image.shape[:2][::(- 1)]
    image = image.transpose((2, 0, 1))
    image = (image / 255.0)
    data = {'image': image, 'original_size': np.array(size)}
    pred = model(map_tensor(data, (lambda x: x.to(self.device))))
    pred = {k: v[0].cpu().numpy() for (k, v) in pred.items()}
    pred['image_size'] = original_size = data['original_size'][0].numpy()
    if ('keypoints' in pred):
        size = np.array(data['image'].shape[(- 2):][::(- 1)])
        scales = (original_size / size).astype(np.float32)
        pred['keypoints'] = (((pred['keypoints'] + 0.5) * scales[None]) - 0.5)
    return pred
def extract(self, image):
    image = image.astype(np.float32)
    size = image.shape[:2][::(- 1)]
    image = image.transpose((2, 0, 1))
    image = (image / 255.0)
    data = {'image': image, 'original_size': np.array(size)}
    pred = model(map_tensor(data, (lambda x: x.to(self.device))))
    pred = {k: v[0].cpu().numpy() for (k, v) in pred.items()}
    pred['image_size'] = original_size = data['original_size'][0].numpy()
    if ('keypoints' in pred):
        size = np.array(data['image'].shape[(- 2):][::(- 1)])
        scales = (original_size / size).astype(np.float32)
        pred['keypoints'] = (((pred['keypoints'] + 0.5) * scales[None]) - 0.5)
    return pred