CreateML model doesn't work as expected when added to my application (Swift)

I have a trained model to identify squats (good & bad repetitions). It seems to be working perfectly in CreateML when I preview it with some test data, although once I add it to my app the model seems to be inaccurate and the majority of the time mixes up the actions. Does anyone know if the issue is code related or is it something to do with the model itself and how it analyses live data?

Below I have added one of my functions for "Good Squats" which most of the time doesn't even get called (even with lower confidence). The majority of the time the model classes everything as a bad squat even though it is clearly not.

Could the problem be that my dataset doesn't have enough videos?

print("GoodForm")
        squatDetected = true
        
        DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
            self.squatDetected = false
        }
        DispatchQueue.main.async {
            self.showGoodFormAlert(with: confidence)
            AudioServicesPlayAlertSound(SystemSoundID(1322))
        }
    }

Any help would be appreciated.

Replies

Here is the full function

            print("GoodForm")
            squatDetected = true
            
            DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
                self.squatDetected = false
            }
            DispatchQueue.main.async {
                self.showGoodFormAlert(with: confidence)
                AudioServicesPlayAlertSound(SystemSoundID(1322))
            }
        }```

if action == "GoodForm" && confidence > 0.80 && !squatDetected { print("GoodForm") squatDetected = true

        DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
            self.squatDetected = false
        }
        DispatchQueue.main.async {
            self.showGoodFormAlert(with: confidence)
            AudioServicesPlayAlertSound(SystemSoundID(1322))
        }
    }