facebookresearch / sapiens

High-resolution models for human tasks.
https://about.meta.com/realitylabs/codecavatars/sapiens/
Other
4.52k stars 255 forks source link

vis_pose.py: error: the following arguments are required: pose_checkpoint #74

Closed johndpope closed 2 months ago

johndpope commented 2 months ago

background: I have one single body json pose - i want to visualize it how can i do this?

(comfyui) ➜  sapiens git:(main) ✗ python lite/demo/vis_pose.py --input='/home/oem/Desktop/image_3.png' --output-root .
/home/oem/miniconda3/envs/comfyui/lib/python3.11/site-packages/mmengine/optim/optimizer/zero_optimizer.py:11: DeprecationWarning: `TorchScript` support for functional optimizers is deprecated and will be removed in a future PyTorch release. Consider using the `torch.compile` optimizer instead.
  from torch.distributed.optim import \
usage: vis_pose.py [-h] [--det-config DET_CONFIG]
                   [--det-checkpoint DET_CHECKPOINT] [--input INPUT]
                   [--num_keypoints NUM_KEYPOINTS] [--shape SHAPE [SHAPE ...]]
                   [--output-root OUTPUT_ROOT] [--batch_size BATCH_SIZE] [--fp16]
                   [--device DEVICE] [--det-cat-id DET_CAT_ID]
                   [--bbox-thr BBOX_THR] [--nms-thr NMS_THR] [--kpt-thr KPT_THR]
                   [--radius RADIUS] [--heatmap-scale HEATMAP_SCALE]
                   [--flip FLIP]
                   pose_checkpoint
vis_pose.py: error: the following arguments are required: pose_checkpoint

i clone the huggingface repo - 30gb

git clone https://huggingface.co/facebook/sapiens pretrain
export SAPIENS_CHECKPOINT_ROOT=./pretrain
sapiens git:(main) ✗ python lite/demo/vis_pose.py --input='/home/oem/Desktop/image_3.png' --output-root .

then i get error above

when i specify the pth i get this error. python lite/demo/vis_pose.py --input='/home/oem/Desktop/image_3.png' --output-root . '/media/oem/12TB/sapiens/pretrain/sapiens_host/pose/checkpoints/sapiens_1b/sapiens_1b_goliath_best_goliath_AP_640.pth' /home/oem/miniconda3/envs/comfyui/lib/python3.11/site-packages/mmengine/optim/optimizer/zero_optimizer.py:11: DeprecationWarning:TorchScriptsupport for functional optimizers is deprecated and will be removed in a future PyTorch release. Consider using thetorch.compileoptimizer instead. from torch.distributed.optim import \ /home/oem/miniconda3/envs/comfyui/lib/python3.11/site-packages/albumentations/check_version.py:49: UserWarning: Error fetching version info The read operation timed out data = fetch_version_info() Traceback (most recent call last): File "/media/oem/12TB/sapiens/lite/demo/vis_pose.py", line 459, in <module> main() File "/media/oem/12TB/sapiens/lite/demo/vis_pose.py", line 294, in main pose_estimator = load_model(args.pose_checkpoint, USE_TORCHSCRIPT) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/media/oem/12TB/sapiens/lite/demo/vis_pose.py", line 173, in load_model return torch.export.load(checkpoint).module() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/oem/miniconda3/envs/comfyui/lib/python3.11/site-packages/torch/export/__init__.py", line 300, in load return load( ^^^^^ File "/home/oem/miniconda3/envs/comfyui/lib/python3.11/site-packages/torch/_export/__init__.py", line 284, in load version = zipf.read('version').decode().split('.') ^^^^^^^^^^^^^^^^^^^^ File "/home/oem/miniconda3/envs/comfyui/lib/python3.11/zipfile.py", line 1510, in read with self.open(name, "r", pwd) as fp: ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/oem/miniconda3/envs/comfyui/lib/python3.11/zipfile.py", line 1547, in open zinfo = self.getinfo(name) ^^^^^^^^^^^^^^^^^^ File "/home/oem/miniconda3/envs/comfyui/lib/python3.11/zipfile.py", line 1476, in getinfo raise KeyError( KeyError: "There is no item named 'version' in the archive"

rawalkhirodkar commented 2 months ago

@johndpope no pose checkpoint path is provided. Please follow the instructions here: https://github.com/facebookresearch/sapiens/blob/main/lite/docs/POSE_README.md

johndpope commented 2 months ago

that code is designed to bulk extract poses - in my use case is - i have a body pose (using the pose gradio demo on huggingface) - how can i correctly parse it and save it back to an image ?

did you consider using omegaconf / yaml files to keep config stuff in one place? the shell scripts are hard coding the directory paths everywhere to your local directories it maybe ok once or twice - they're everywhere https://github.com/johndpope/IMF/blob/main/config.yaml

https://github.com/johndpope/IMF/blob/main/train.py#L358 Screenshot from 2024-09-12 05-25-53

johndpope commented 2 months ago

fyi - this is what i was hoping to achieve in this repo - https://github.com/johndpope/EAI/blob/main/pose_vis.py

python pose_vis.py '/home/oem/Desktop/image_1.png'  test.png output.json

just input the image - get the output (body json / output.png)

-obviously i cherry pick the example pose from huggingface https://huggingface.co/spaces/facebook/sapiens-pose/tree/main

rawalkhirodkar commented 2 months ago

@johndpope there is no script to visualize the json as input in this repository - no documentation points to this.

You are on the right track to use the hugging-face pose-space code as a reference. If you got the json from the demo, you also get the keypoint visualized image in the demo as well which you can download directly.