Skip to content

Commit dcd19d8

Browse files
Merge pull request #4 from rizzojr01/main
Add runtime step detection configuration API with SQLite backend and Pydantic models
2 parents 98676d3 + 49d65bf commit dcd19d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2615
-3306
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.github/workflows/ci-cd.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
name: Deploy
11+
runs-on: ubuntu-latest
12+
env:
13+
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
14+
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
15+
16+
steps:
17+
- name: Checkout Repository
18+
uses: actions/checkout@v4
19+
20+
- name: Install Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.10"
24+
25+
- name: Install Modal
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install modal
29+
30+
- name: Prepare Git State
31+
run: |
32+
git reset --hard HEAD
33+
git clean -fd
34+
35+
- name: Deploy Modal App
36+
run: |
37+
modal deploy modal_app.py

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.env
1+
.env
2+
__pycache__

BUILD_ENHANCEMENT_SUMMARY.md

Lines changed: 0 additions & 171 deletions
This file was deleted.

MODAL_DEPLOYMENT.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# 🚀 Modal Deployment Guide
2+
3+
This guide provides step-by-step instructions for deploying the Step Detection AI application using Modal, a serverless cloud platform optimized for machine learning workloads.
4+
5+
## 📋 Table of Contents
6+
7+
- [Prerequisites](#-prerequisites)
8+
- [Quick Start](#-quick-start)
9+
10+
## 📋 Prerequisites
11+
12+
- **Python 3.10+** installed on your local machine
13+
- **Modal account** (sign up at [modal.com](https://modal.com))
14+
15+
16+
## ⚡ Quick Start
17+
18+
For experienced developers who want to get up and running quickly:
19+
20+
```bash
21+
# 1. Clone and setup
22+
git clone https://github.com/rizzojr01/Step-Detection-using-AI-Deep-Learning.git
23+
cd Step-Detection-using-AI-Deep-Learning
24+
python3 -m venv venv && source venv/bin/activate
25+
26+
# 2. Install Modal
27+
pip install modal==1.0.0
28+
29+
# 3. Authenticate with Modal
30+
modal token new
31+
32+
# 4. Deploy
33+
modal deploy modal_app.py
34+
```
35+

__pycache__/main.cpython-311.pyc

1013 Bytes
Binary file not shown.

config/config.db

12 KB
Binary file not shown.

config/config.yaml

Lines changed: 47 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,65 @@
11
# Step Detection Configuration
22

3-
# Model Configuration
4-
model:
5-
input_shape: [6] # 6 sensor features (3 accel + 3 gyro)
6-
output_classes: 3 # No Label, Start, End
7-
architecture: "CNN" # Original high-accuracy CNN architecture
8-
framework: "TensorFlow"
3+
# Step Detection Configuration
4+
detection:
5+
# Sensor buffer and thresholds
6+
window_size: 10 # Number of recent sensor readings to consider
7+
start_threshold: 0.3 # Threshold for step start detection (increased from 0.3)
8+
end_threshold: 0.3 # Threshold for step end detection (increased from 0.3)
99

10-
# Training Configuration
11-
training:
12-
epochs: 50 # Increased for better convergence
13-
batch_size: 32 # Reduced for better gradient updates
14-
learning_rate: 0.001
15-
validation_split: 0.2
16-
early_stopping_patience: 10
17-
reduce_lr_patience: 5
10+
# AI Model confidence requirements
11+
ai_high_confidence_threshold: 0.75 # High confidence threshold for AI-only detection
12+
ai_sensor_disagree_threshold: 0.80 # Required AI confidence when sensors disagree
1813

19-
# Model architecture parameters
20-
dropout_rate: 0.3 # Increased to reduce overfitting to small movements
21-
regularization: 0.001 # L2 regularization factor
14+
# Motion detection thresholds (balanced for accuracy)
15+
motion_threshold: 11.0 # Acceleration magnitude threshold for step detection (above gravity + margin)
16+
gyro_threshold: 1.5 # Gyroscope magnitude threshold for step detection (increased to reduce false positives)
2217

23-
# Class balancing
24-
use_class_weights: true # Automatically calculate class weights
18+
# Timing constraints
19+
min_step_interval: 0.4 # Minimum time (seconds) between step detections
2520

26-
# Data augmentation (if needed)
27-
data_augmentation: false
28-
noise_factor: 0.01
21+
# Advanced filtering to reduce false positives (made less restrictive)
22+
enable_motion_variance_filter: true # Only detect steps with varying motion patterns
23+
min_motion_variance: 1.0 # Minimum variance in motion to consider it walking (lowered from 2.0)
24+
enable_stillness_detection: true # Detect when user is stationary
25+
stillness_threshold: 0.8 # Max motion variance when considered "still" (lowered from 1.5)
2926

30-
# Detection Configuration
31-
detection:
32-
window_size: 50
33-
# Enhanced sensitivity controls
34-
confidence_threshold: 0.001 # Lowered to match model output range
35-
magnitude_threshold: 8.0 # Reduced from 15.0 to capture normal walking patterns
27+
# Advanced detection settings (less restrictive)
28+
enable_peak_detection: true # Enable peak-based detection for better accuracy
29+
enable_adaptive_thresholds: false # Disable adaptive thresholds to prevent over-adjustment
30+
motion_sensitivity: 0.9 # Sensitivity multiplier (closer to 1.0 = less adjustment)
3631

37-
# Model prediction thresholds
38-
prediction_confidence_min: 0.5 # Minimum confidence to consider any prediction
39-
step_class_threshold: 0.6 # Specific threshold for step classes (1=start, 2=end)
32+
# Hybrid detection mode
33+
enable_hybrid_detection: true # Use multiple detection methods
34+
require_all_conditions: false # Don't require ALL conditions (OR logic instead of AND)
4035

41-
# Filtering parameters
42-
enable_magnitude_filter: true # Enable/disable magnitude-based filtering
43-
enable_confidence_filter: true # Enable/disable confidence-based filtering
44-
temporal_smoothing: false # Enable temporal smoothing (future feature)
36+
# Peak detection parameters
37+
peak_prominence: 2.0 # Minimum prominence for peak detection
38+
peak_distance: 5 # Minimum distance between peaks (in samples)
4539

46-
# Advanced filtering options
47-
adaptive_magnitude: true # Adjust magnitude threshold based on recent activity
48-
min_magnitude_threshold: 6.0 # Absolute minimum to filter out phone shakes
49-
max_magnitude_threshold: 25.0 # Maximum to filter out extreme movements
50-
51-
# Data Configuration
52-
data:
53-
raw_data_path: "data/raw"
54-
processed_data_path: "data/processed"
55-
model_save_path: "models"
40+
# Buffer settings
41+
processing_buffer_size: 100 # Size of processing times buffer
5642

5743
# API Configuration
5844
api:
5945
host: "0.0.0.0"
6046
port: 8000
6147
reload: true
6248
title: "Step Detection API"
63-
version: "1.0.0"
49+
version: "2.0.0"
50+
51+
# Model Configuration (currently used values only)
52+
model:
53+
input_shape: [6] # 6 sensor features (3 accel + 3 gyro)
54+
output_classes: 3 # No Label, Start, End
55+
56+
# Data Configuration
57+
data:
58+
raw_data_path: "data/raw"
59+
processed_data_path: "data/processed"
60+
model_save_path: "models"
6461

65-
# Logging Configuration
66-
logging:
67-
level: "INFO"
68-
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
69-
log_file: "logs/step_detection.log"
62+
# Debug Configuration
63+
debug:
64+
enable_step_detection_logs: true
65+
log_only_on_steps: false

0 commit comments

Comments
 (0)