Pascal Person Part is a single-person human parsing dataset with 3 000+ images focused on body part segmentation.
1from transformers import AutoImageProcessor, AutoModelForSemanticSegmentation
2from PIL import Image
3import torch
4
5model = AutoModelForSemanticSegmentation.from_pretrained("pirocheto/schp-pascal-7", trust_remote_code=True)
6processor = AutoImageProcessor.from_pretrained("pirocheto/schp-pascal-7", trust_remote_code=True)
7
8image = Image.open("photo.jpg").convert("RGB")
9inputs = processor(images=image, return_tensors="pt")
10
11with torch.no_grad():
12 outputs = model(**inputs)
13
14# outputs.logits — (1, 7, 512, 512) raw logits
15# outputs.parsing_logits — (1, 7, 512, 512) refined parsing logits
16# outputs.edge_logits — (1, 1, 512, 512) edge prediction logits
17seg_map = outputs.logits.argmax(dim=1).squeeze().numpy() # (H, W), values in [0, 6]
1id2label = model.config.id2label
2print(id2label[1]) # → "Head"
1import onnxruntime as ort
2import numpy as np
3from huggingface_hub import hf_hub_download
4from transformers import AutoImageProcessor
5from PIL import Image
6
7model_path = hf_hub_download("pirocheto/schp-pascal-7", "onnx/schp-pascal-7-int8-static.onnx")
8processor = AutoImageProcessor.from_pretrained("pirocheto/schp-pascal-7", trust_remote_code=True)
9
10sess_opts = ort.SessionOptions()
11sess_opts.intra_op_num_threads = 8
12sess = ort.InferenceSession(model_path, sess_opts, providers=["CPUExecutionProvider"])
13
14image = Image.open("photo.jpg").convert("RGB")
15inputs = processor(images=image, return_tensors="np")
16logits = sess.run(["logits"], {"pixel_values": inputs["pixel_values"]})[0]
17seg_map = logits.argmax(axis=1).squeeze() # (H, W)