6 Replies
      Latest reply on Aug 14, 2019 10:55 PM by AthenaY
      AthenaY Level 1 Level 1 (0 points)

        My trained model is working fine on Xcode (11 Beta) on my computer but when deployed to my iphone to try it out, it is not predicting anything. Anyone encountered this problem and has an idea why or has a solution? Thank-you!

        • Re: Model not predicting when deployed on phone
          kerfuffle Level 3 Level 3 (110 points)

          What do you mean by "not predicting anything"?

           

          Is it giving an error?

           

          Is it giving the wrong predictions?

           

          Is it not giving _any_ predictions at all?

            • Re: Model not predicting when deployed on phone
              AthenaY Level 1 Level 1 (0 points)

              It is not giving out the predicted Label like it does in Simulation. It just pops up the Catch error message that I put in. It's like it just skipped the "do" part of the function where I call the model. But why would it do so when deplyed on the phone but works fine when I launched it in Simulation?

                • Re: Model not predicting when deployed on phone
                  kerfuffle Level 3 Level 3 (110 points)

                  What is the error message?

                    • Re: Model not predicting when deployed on phone
                      AthenaY Level 1 Level 1 (0 points)

                      I really apreciate your time in trying to help me. I feel so stuck. The error message is the catch error message I setup within the function. It pops up on the screen like I intended it to do but it should be the predicted label instead. It's like the "do" section of the function that calls out the model is skipped and the "catch" error messages were displayed instead. Any idea why it works on the simulator but not on the device? Is it because the trained model somehow not deploying together with the rest of the app? But why? I don't know how to fix this.

                       

                      I have tried updating my iPhone software to the latest version. I have checked to make sure data captured on the phone is indeed captured for the prediction.

                       

                      Below is the function.

                       

                      The message below is displayed instead of "The Language is" followed by the predicted label like in the simulator.

                      "Error" "Sorry, seems like we are having some problems predicting"

                       

                       

                      @objc func PredictLanguage(){
                        let model = MyLanguageClassifier_1()

                        let title: String
                        let message: String

                        do {
                        let prediction = try model.prediction(text: Speech)

                        let ResultLanguage = prediction.label

                        message = ResultLanguage
                        title = "The Language is"

                        } catch {
                        title = "Error"
                        message = "Sorry, seems like we are having some problems predicting"
                        }

                        let ac = UIAlertController(title: title, message: message, preferredStyle: .alert)
                        ac.addAction(UIAlertAction(title: "OK", style: .default))
                        present(ac, animated: true)
                      }