Recently, I tried to inference the DWPose (improved OpenPose) preprocessor for Diffusers and was shocked by how complicated it actually is! So, I decided to change that!
The goal of Easy DWPose is to provide a generic, reliable, and easy-to-use interface for making skeletons for ControlNet.
- Easy installation!
- Automatic checkpoint downloading.
- Generic class to either import in Jupyter or to run on a video/images.
- Code that is easy to read and modify.
- Choose GPU for multi-gpu inference!
- Custom drawing functions: convenient interface for modifying how you draw skeletons.
pip install easy-dwpose
git clone git@github.com:reallyigor/easy_dwpose.git
cd easy_dwpose
pip install -e .
import torch
from PIL import Image
from easy_dwpose import DWposeDetector
# You can use a different GPU, e.g. "cuda:1"
device = "cuda:0" if torch.cuda.is_available() else "cpu"
detector = DWposeDetector(device=device)
input_image = Image.open("assets/pose.png").convert("RGB")
skeleton = detector(input_image, output_type="pil", include_hands=True, include_face=True)
skeleton.save("skeleton.png")
Input | Output |
---|---|
|
|
python scripts/inference_on_video.py --input assets/dance.mp4 --output_path result.mp4
Input | Output |
---|---|
|
|
python scripts/inference_on_folder.py --input assets/ --output_path results/
By default, we use standart skeleton drawing function but several projects change it (e.g. MusePose). Modify it or write your own from scratch!
from PIL import Image
from easy_dwpose import DWposeDetector
from easy_dwpose.draw.musepose import draw_pose as draw_pose_musepose
detector = DWposeDetector(device="cpu")
input_image = Image.open("assets/pose.png").convert("RGB")
skeleton = detector(input_image, output_type="pil", draw_pose=draw_pose_musepose, draw_face=False)
skeleton.save("skeleton.png")
We thank the original authors of the DWPose for their incredible models!
Thanks for open-sourcing!