initModel method

Future<void> initModel(
  1. AppLocalizations localizations
)

Initializes the classification model for local predictions.

Loads the machine learning model required for local image classification.

Parameters:

  • localizations: Used for localized error messages

Throws:

  • Exception if model loading fails

Implementation

Future<void> initModel(AppLocalizations localizations) async {
  try {
    await _repository.loadModel();
  } catch (e) {
    if (e.toString().contains("Model loading failed")) {
      _errorMessage = localizations.classificationServiceErrorModelLoadingFailed;
    } else {
      _errorMessage = localizations.errorFailedToLoadModel(e.toString());
    }
    notifyListeners();
  }
}