garmentiq.garment_classes
The predefined garment classes and their measurement instructions.
garment_classes maps each supported garment to the number of landmarks the detection
model predicts for it, the slice of the model output those landmarks occupy, and the
path to the JSON instruction defining its measurements. Instruction files are bundled
with the package and resolved to absolute paths at import time.
Pass a modified copy as class_dict to use your own measurement instructions.
1"""The predefined garment classes and their measurement instructions. 2 3`garment_classes` maps each supported garment to the number of landmarks the detection 4model predicts for it, the slice of the model output those landmarks occupy, and the 5path to the JSON instruction defining its measurements. Instruction files are bundled 6with the package and resolved to absolute paths at import time. 7 8Pass a modified copy as `class_dict` to use your own measurement instructions. 9""" 10from importlib.resources import files 11 12package_name = __name__.split(".")[0] 13 14 15def _instruction_path(filename: str) -> str: 16 """Resolve a bundled instruction JSON to an absolute filesystem path.""" 17 return str(files(package_name) / "instruction" / filename) 18 19 20garment_classes = { 21 "long sleeve dress": { 22 "num_predefined_points": 37, 23 "index_range": (219, 256), 24 "instruction": _instruction_path("long sleeve dress.json") 25 }, 26 "long sleeve top": { 27 "num_predefined_points": 33, 28 "index_range": (25, 58), 29 "instruction": _instruction_path("long sleeve top.json") 30 }, 31 "short sleeve dress": { 32 "num_predefined_points": 29, 33 "index_range": (190, 219), 34 "instruction": _instruction_path("short sleeve dress.json") 35 }, 36 "short sleeve top": { 37 "num_predefined_points": 25, 38 "index_range": (0, 25), 39 "instruction": _instruction_path("short sleeve top.json") 40 }, 41 "shorts": { 42 "num_predefined_points": 10, 43 "index_range": (158, 168), 44 "instruction": _instruction_path("shorts.json") 45 }, 46 "skirt": { 47 "num_predefined_points": 8, 48 "index_range": (182, 190), 49 "instruction": _instruction_path("skirt.json") 50 }, 51 "trousers": { 52 "num_predefined_points": 14, 53 "index_range": (168, 182), 54 "instruction": _instruction_path("trousers.json") 55 }, 56 "vest": { 57 "num_predefined_points": 15, 58 "index_range": (128, 143), 59 "instruction": _instruction_path("vest.json") 60 }, 61 "vest dress": { 62 "num_predefined_points": 19, 63 "index_range": (256, 275), 64 "instruction": _instruction_path("vest dress.json") 65 } 66} 67"""dict: A comprehensive dictionary defining various garment classes and their properties for GarmentIQ. 68 69Each key in this dictionary represents a specific garment type (e.g., "long sleeve dress"). 70The value associated with each garment type is a dictionary containing: 71 - "num_predefined_points" (int): The total number of predefined (detected) 72 keypoints for this garment class. 73 - "index_range" (tuple): A tuple (start_index, end_index) specifying the 74 slice of the model's output that corresponds to the predefined keypoints 75 for this garment. These indices are 0-based and exclusive of the end_index. 76 - "instruction" (str): The file path to a JSON schema that details the 77 specific landmarks (predefined and derivable) and measurements for this 78 garment type. These paths are resolved using `importlib.resources.files` 79 to ensure they are correctly located within the installed package. 80 81This dictionary serves as a central registry for the GarmentIQ system to 82understand and process different types of clothing. 83"""
dict: A comprehensive dictionary defining various garment classes and their properties for GarmentIQ.
Each key in this dictionary represents a specific garment type (e.g., "long sleeve dress").
The value associated with each garment type is a dictionary containing:
- "num_predefined_points" (int): The total number of predefined (detected) keypoints for this garment class.
- "index_range" (tuple): A tuple (start_index, end_index) specifying the slice of the model's output that corresponds to the predefined keypoints for this garment. These indices are 0-based and exclusive of the end_index.
- "instruction" (str): The file path to a JSON schema that details the specific landmarks (predefined and derivable) and measurements for this garment type. These paths are resolved using
importlib.resources.filesto ensure they are correctly located within the installed package.
This dictionary serves as a central registry for the GarmentIQ system to understand and process different types of clothing.