Skip to content

Controlnet-Aux#

Pose Detector#

from PIL import Image
from vision_agent_tools.models.controlnet_aux import Image2Pose

# Path to your test image
test_image_path = "path/to/your/image.jpg"

# Load the image
image = Image.open(test_image_path)
# Create the Image2Pose instance
image_2_pose = Image2Pose()

# Run pose detection and get the results
results = image_2_pose(image)

# Optional: Save the result image (assuming results is a PIL Image)
# results.save("result.png")

print("Pose detection complete!")
Pose detection
Pose Detection Result

Image2Pose #

A class that simplifies human pose detection using a pre-trained Openpose model.

This class provides a convenient way to run pose detection on images using a pre-trained Openpose model from the controlnet_aux library. It takes a PIL Image object as input and returns the predicted pose information.

__call__(image) #

Performs pose detection on a PIL image and returns the results.

This method takes a PIL Image object as input and runs the loaded Openpose detector on it. The predicted pose information is then resized to match the original image size and returned.

Parameters:

Name Type Description Default
image Image

The input image for pose detection.

required

Returns:

Type Description
Image

PIL.Image: The image with the predicted pose information (format might vary depending on the specific OpenposeDetector implementation).

__init__() #

Initializes the Image2Pose object with a pre-trained Openpose detector.

This method loads a pre-trained Openpose model from the specified model hub ("lllyasviel/Annotators" in this case). The loaded detector is stored as an attribute for future use.