Life Saving watchOS ML App

watchOS ML Apps Save Lives Using Core ML / HealthKit

YLabZ
6 min readMay 8, 2024

The Hard Fact

Every day, about 37 people in the United States die in drunk-driving crashes — that’s one person every 39 minutes.

Do not become a statistic (AI Generated — no person was hurt in making these images)

Expository Idea

Lets think of a watchOS ML app which can address this …

Lets build it on watchOS 10+

With good design

Idea:

1. Read the text of a number 1 to 9

2. Use you finger and draw the number

3. The ML will try to read it.

4. If it can NOT read the number you are drawing it checks your health …

5. If the ML thinks you’re drunk it will call UBER otherwise it will unlock your car.

DrunkWatch

DrunkWatch is a system that uses your watch sensors to determine if you are too intoxicated to drive. It analyzes your walking, writing(when entering a 3 digit code) and bio/health sensors to determine if you are safe to drive.

ML and sensors keep you out of your car when you should not be driving.

3 ML Systems to analyze:

  1. walking to your car
  2. bio / health sensors
  3. writing a 3 digit code

All working together to determine the state of your mind.

Overview of ML Development

Walking Cadence

Research

In this paper, we investigate detecting drinkers’ intoxication levels from their gait by using neural networks to analyze sensor data gathered from their smartphone.

Harmful use of alcohol is responsible for 5.1% of the global burden of disease. Recent work aimed at promoting healthier drinking habits has shown promise for the effectiveness of just-in-time adaptive interventions delivered on mobile phones just before the onset of heavy drinking episodes. This project used only non-sensitive accelerometer data collected from mobile phones, examined different deep learning architectures and developed a reliable classifier which detected periods of heavy drinking with 96.2% accuracy.

PDF: https://cs230.stanford.edu/projects_winter_2021/reports/70769718.pdf

Data Set

Lets build the model from the data.

Example Project:

Just-in-time adaptive interventions (JITAIs) are a promising area of research in health domains, and have been used to detect heavy drinking episodes as they occur. This projects aims to improve on the study “Learning to Detect Heavy Drinking Episodes Using Smartphone Accelerometer Data” (Killian et al., 2019). The study provides smartphone accelerometer data from 13 participants before and after a bar crawl and their blood alcohol content via transdermal alcohol concentration (TAC). Given a 10-second window of non-zero accelerometer data, I predict whether the TAC is above 0.08 (intoxicated).

Helper Functions

Classify motion data

Analyzing Hand Writing

We use Apple ML, a already trained model so no need for training.

https://developer.apple.com/machine-learning/models/

Sample Project:

Example Code:

The finger trace is captured and analyzed.

Finger trace to use in determination

Classify the image (0–9) and alarm if the code is wrong or percentages is too low.

func classifyImage() {
guard let model = try? MNISTClassifier(configuration: MLModelConfiguration()) else {
print("Failed to load model")
return
}

// Convert drawn image to UIImage
let image = UIImage(view: DrawingView(path: path))

// Convert the image to a format suitable for the model
guard let pixelBuffer = image?.pixelBuffer(width: 28, height: 28) else {
print("Failed to convert image to pixel buffer")
return
}

// Perform classification
do {
let prediction = try model.prediction(image: pixelBuffer)
predictedDigit = prediction.classLabel
} catch {
print("Error making prediction: \(error)")
predictedDigit = "Error"
}
}

Video Tutorial:

Unlocking the Door

Car Keys works through an NFC-based Digital Key 2.0 specification that’s developed by the Car Connectivity Consortium (CCC), which Apple is a member of. The Digital Key 2.0 specification establishes a secure connection between mobile devices and vehicles over NFC.

For younger drivers, there are limits for acceleration, top speed, traction control, and stereo volume.

Porsche with needed technology:

  • 2017–2023 718 2017–2023 Panamera 2017–2023 Macan 2017–2023 Cayenne 2017–2023 911 2020–2023 Taycan
Driven by Dreams — Special Edition

Future Work

Passive monitoring

The app could monitor gait patterns or other user interactions throughout the evening, building a baseline for when the user is sober. Significant deviations from this baseline could trigger a warning or prompt the user to seek alternative transportation.

Important Note

It’s crucial to remember that DrunkWatch is a concept, and no technology is foolproof. Even with these features, it shouldn’t be solely relied upon to determine someone’s fitness to drive. Always prioritize safety and use common sense. If you feel intoxicated, using a designated driver or ride-hailing service is the best course of action.

Resources:

--

--

No responses yet