Skip to main content

Face Parsers

Project description

face-parser

1. Face Segmentation

1.1. BiSeNet

from visage.bisenet import BiSeNetFaceParser
from visage.visualize import apply_colormap

img = load_img()  # torch.Tensor [3, H, W] in range [-1, 1]

face_parser = BiSeNetFaceParser()
segmentation_mask = face_parser.parse(img)

# Plotting
segmentation_mask_colored = apply_colormap(segmentation_mask)  # Colorizes each class with a distinct color for better viewing
plt.imshow(segmentation_mask_colored)

2. Face Bounding Boxes

2.1. FaceBoxesV2

from visage.bounding_boxes.face_boxes_v2 import FaceBoxesV2

img = load_img()  # np.ndarray [H, W, 3] in range [0, 255]

detector = FaceBoxesV2()
detected_bboxes = detector.detect(img)

# Plotting
cv2.rectangle(img, detected_bboxes[0].get_point1(), detected_bboxes[0].get_point2(), (255, 0, 0), 10)
plt.imshow(img)

3. Facial Landmarks

3.1. PIPNet

from visage.landmark_detection.pipnet import PIPNet

img = load_img()  # np.ndarray [H, W, 3] in range [0, 255]
detected_bboxes = ...  # <- from step 2.

pip_net = PIPNet()
landmarks = pip_net.forward(img, detected_bboxes[0])

# Plotting
for x, y in landmarks:
    cv2.circle(img, (int(x), int(y)), 5, (255, 0, 0), -1)

plt.imshow(img)

4. Background Matting

4.1. BackgroundMattingV2

from visage.matting.background_matting_v2 import BackgroundMattingV2

img = load_img(...)  # np.ndarray [H, W, 3] in range [0, 255]
bg_img = load_img(...)  # np.ndarray [H, W, 3] in range [0, 255]. Should be the same viewpoint but without the foreground

background_matter = BackgroundMattingV2()
alpha_images = background_matter.parse([img], [bg_img])

plt.imshow(alpha_images[0])
Image Background Foreground Mask

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

visage-0.2.12.tar.gz (215.6 kB view details)

Uploaded Source

File details

Details for the file visage-0.2.12.tar.gz.

File metadata

  • Download URL: visage-0.2.12.tar.gz
  • Upload date:
  • Size: 215.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for visage-0.2.12.tar.gz
Algorithm Hash digest
SHA256 30e021a7fa69396bbbfa4a210be4c30a3a46c479506fa53dd14ab75de62f7718
MD5 f1b0c69f1ff647793512ed3ed5b9dd99
BLAKE2b-256 be083026b0f136dd661484afd6ce768a55d0d073a11d988f685230e4d40b1c4e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page