Skip to content

Commit

Permalink
docs: improve error messages
Browse files Browse the repository at this point in the history
Signed-off-by: Dale Lane <dale.lane@uk.ibm.com>
  • Loading branch information
dalelane committed Mar 20, 2022
1 parent c05a56a commit da02a75
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/com/kylecorry/ml4k/ML4KComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ public final class ML4KComponent extends AndroidNonvisibleComponent {
private final static String EXPLAIN_API_KEY_TYPE_NUMBERS = "You created a machine learning project to recognise numbers, so you can only use the numbers ML blocks in this project.";
private final static String EXPLAIN_API_KEY_TYPE_IMAGES = "You created a machine learning project to recognise images, so you can only use the images ML blocks in this project.";
private final static String EXPLAIN_API_KEY_TYPE_SOUNDS = "You created a machine learning project to recognise sounds, so you cannot use that block";
private final static String EXPLAIN_ML_MODEL_NEEDED = "Please train a machine learning model before you try to do this.";
private final static String EXPLAIN_ML_MODEL_NEEDED = "Please train a machine learning model before you try to do this. You must do this in your App Inventor project, using the 'TrainNewModel' block.";
private final static String EXPLAIN_ML_MODEL_NOTREADY = "Your machine learning model is still training. Please wait for this to complete.";
private final static String EXPLAIN_ML_MODEL_FAILED = "Sorry! Your machine learning model failed to train.";



Expand Down Expand Up @@ -478,9 +480,19 @@ private void checkTensorFlowJsStatus() {
private void classifyImageWithTensorflow(final String path) {
initialiseTensorFlow();

if (!webPageObj.getModelStatus().equals("Available")) {
displayErrorMessage(EXPLAIN_ML_MODEL_NEEDED);
return;
switch (webPageObj.getModelStatus()) {
case "Not trained":
displayErrorMessage(EXPLAIN_ML_MODEL_NEEDED);
return;
case "Failed":
displayErrorMessage(EXPLAIN_ML_MODEL_FAILED);
return;
case "Training":
displayErrorMessage(EXPLAIN_ML_MODEL_NOTREADY);
return;
case "Available":
// yay, we're all good!
break;
}

runInBackground(new Runnable() {
Expand Down

0 comments on commit da02a75

Please sign in to comment.