loadLabelMap function

Future<List<String>> loadLabelMap()

Reads the bundled COCO labelmap (labelmap.txt) from package assets.

Returns the list of label strings, indexable by class index. Some entries are placeholder ??? strings to keep alignment with the original COCO IDs.

Implementation

Future<List<String>> loadLabelMap() async {
  final raw = await rootBundle.loadString(
    'packages/object_detection/assets/models/$_labelMapAsset',
  );
  return raw
      .split('\n')
      .map((s) => s.trim())
      .where((s) => s.isNotEmpty)
      .toList(growable: false);
}