loadClassificationModel static method

Future<ClassificationModel> loadClassificationModel(
  1. String path,
  2. int imageWidth,
  3. int imageHeight, {
  4. String? labelPath,
})

Sets pytorch model path and returns Model

Implementation

static Future<ClassificationModel> loadClassificationModel(
    String path, int imageWidth, int imageHeight,
    {String? labelPath}) async {
  String absPathModelPath = await _getAbsolutePath(path);
  int index = await ModelApi()
      .loadModel(absPathModelPath, null, imageWidth, imageHeight, 0);
  List<String> labels = [];
  if (labelPath != null) {
    if (labelPath.endsWith(".txt")) {
      labels = await _getLabelsTxt(labelPath);
    } else {
      labels = await _getLabelsCsv(labelPath);
    }
  }

  return ClassificationModel(index, labels);
}