Skip to content

Latest commit

 

History

History
118 lines (86 loc) · 3.28 KB

File metadata and controls

118 lines (86 loc) · 3.28 KB

Detection Optimization for Multiple Seats

Problem Analysis

The model was unable to detect multiple seats due to overly aggressive thresholds:

  1. High confidence threshold (0.15) - Chairs have lower confidence scores than people
  2. Low IOU threshold (0.25) - Was filtering out valid overlapping detections
  3. Strict SORT tracker - Required 2 hits before tracking, missing quick appearances
  4. High SORT IOU (0.2) - Was merging close seats into single tracks

Solutions Implemented

1. Model Detection Parameters

Confidence Threshold: 0.15 → 0.1

  • Lower threshold allows detection of chairs with lower confidence
  • Captures more seat candidates
  • Trade-off: Slight increase in false positives (acceptable for library use)

IOU Threshold: 0.25 → 0.4

  • Higher IOU allows overlapping bounding boxes to coexist
  • Critical for detecting multiple chairs in close proximity
  • Prevents NMS from suppressing valid detections

2. SORT Tracker Parameters

Max Age: 5 → 3

  • Faster cleanup of lost tracks
  • More responsive to scene changes

Min Hits: 2 → 1

  • Immediately starts tracking detected objects
  • No warmup period needed
  • Better for detecting all seats from first frame

IOU Threshold: 0.2 → 0.15

  • Lower threshold prevents merging of close seats
  • Each seat maintains separate track ID
  • Better spatial separation

Files Modified

  1. .env

    • MODEL_CONF_THRESHOLD=0.1
    • MODEL_IOU_THRESHOLD=0.4
    • SORT_MAX_AGE=3
    • SORT_MIN_HITS=1
    • SORT_IOU_THRESHOLD=0.15
  2. docker-compose.yml

    • Updated default values for all thresholds
    • Ensures consistency in containerized deployment
  3. api/services/frame_processor.py

    • Updated default parameters in init
    • Updated SORT tracker initialization

Expected Results

More seats detected - Lower confidence catches chairs with partial occlusion ✅ Separate tracking - Each chair gets unique ID, no merging ✅ Faster response - Min hits = 1 means immediate tracking ✅ Better spacing - Lower SORT IOU prevents close seats from merging

How to Apply

For Local Development:

# Restart the server to pick up .env changes
python -m uvicorn api.main:app --reload

For Docker Deployment:

# Rebuild and restart containers
docker-compose down
docker-compose up --build -d

Testing Recommendations

  1. Test with multiple chairs in close proximity
  2. Verify each chair gets separate seat ID
  3. Check occupancy detection with people sitting
  4. Monitor for false positives and adjust if needed

Fine-Tuning Guide

If you need to adjust further:

Too many false positives?

  • Increase MODEL_CONF_THRESHOLD (try 0.12)

Seats still merging?

  • Decrease SORT_IOU_THRESHOLD (try 0.1)

Missing quick movements?

  • Keep SORT_MIN_HITS=1

Tracks disappearing too fast?

  • Increase SORT_MAX_AGE (try 5)

Trade-offs

Parameter Benefit Cost
Lower confidence More detections More false positives
Higher IOU Less suppression Possible duplicates
Min hits = 1 Immediate tracking Less stable tracking
Lower SORT IOU Better separation Possible track switches

Validation

✅ Docker compose config validated ✅ Python syntax checked ✅ All parameters synchronized across files ✅ Ready for deployment