Day 72: Setting up SCHP inference: sleeve/collar/torso regions
Running parsing on your cutouts
Run a pretrained human-parsing model on your person cutouts to get region maps. The output is an image where each pixel's value is a region label (0=background, 1=hat, 5=upper-clothes, 9=pants, etc., depending on the label set — LIP and ATR are common). From this map you extract per-region masks and their spatial extents, which feed measurement.
import numpy as np
# parsing_map: HxW array of region-label ids (from SCHP inference)
UPPER_CLOTHES, PANTS = 5, 9 # label ids depend on the parsing label set
def region_extent(parsing_map, label):
ys, xs = np.where(parsing_map == label)
if len(xs) == 0:
return None
return {
"width_px": int(xs.max() - xs.min()),
"height_px": int(ys.max() - ys.min()),
"pixel_count": int(len(xs)), # area, for a coverage sanity check
}
torso = region_extent(parsing_map, UPPER_CLOTHES) # chest-width sourceLabel sets differ — verify before trusting
Parsing models use different label vocabularies (LIP has 20 classes, ATR 18, others vary). Blindly assuming 'label 5 = torso' is a silent-bug generator. Print and visualize the label map on a known image first, confirm which id is which region, then build on it. This is the segmentation-era version of Stage 0's 'always imshow your intermediates'.
Key terms
- Parsing label set
- The specific vocabulary of region classes a parsing model uses (e.g. LIP, ATR) — must be verified before use.
- Region extent
- The spatial bounds (width, height, area) of a parsed region, used as a measurement source.
Before using "label 5 = upper-clothes" from a parsing model, what should you do?