How makejian/pet-behavior-recognition works
This repository is a cat-video analysis application: a CLI or Streamlit user supplies video or a camera feed, and the pipeline produces tracked cat poses, behavior labels, visualized video, and structured JSON. Its principal runtime stages are detection, tracking, pose estimation, temporal stabilization, and behavior recognition. It also includes a separate dataset-preparation and model-training workflow for custom 27-keypoint pose models and optional YOLO detectors. Runtime connections are supported by the pipeline excerpt and source index; training-stage links are documented in the README.
Main entry points: cat_pose_pipeline.py Frame pipeline · scripts Dataset preparation · app.py Interactive app · run.py Batch CLI
Components 20
User Entry
- Batch CLI
run.py - Interactive app
app.py
Video Analysis
- Frame pipeline
src/cat_pose_pipeline.py - Cat detection
src/detector.py - Multi-object tracking
src/tracker.py - Pose estimation
src/pose_estimator.py - Temporal stabilization
src/smoothing.py - Behavior recognition
src/behavior.py - JSON and geometry utilities
src/utils.py
Results
- Pose rendering
src/render.py - Annotated video
src/cat_pose_pipeline.py - Frame JSON
src/cat_pose_pipeline.py
Data and Training
- Labeled pose data
data/annotations - Annotation conversion
scripts/convert_labelstudio_to_coco.py - Dataset preparation
scripts - Pose model training
scripts/train_pose.py - Detector training
scripts/train_detector.py - Model configurations
pretrained/rtmpose
Other components
- Video analyst
- Video or camera
Connections 22
- Video analyst → Batch CLI: runs batch
README.md - Video analyst → Interactive app: starts analysis
app.py - Video or camera → Frame pipeline: provides frames
README.md - Video or camera → Interactive app: camera or upload
app.py - Batch CLI → Frame pipeline: configures and runs
run.py - Interactive app → Frame pipeline: processes frames
app.py - Frame pipeline → Cat detection: detects cats
src/cat_pose_pipeline.py - Frame pipeline → Multi-object tracking: assigns identities
src/cat_pose_pipeline.py - Frame pipeline → Pose estimation: estimates keypoints
src/cat_pose_pipeline.py - Frame pipeline → Temporal stabilization: stabilizes poses
src/cat_pose_pipeline.py - Frame pipeline → Behavior recognition: classifies behavior
src/cat_pose_pipeline.py - Frame pipeline → Pose rendering: draws results
src/cat_pose_pipeline.py - Frame pipeline → JSON and geometry utilities: uses helpers
src/cat_pose_pipeline.py - Frame pipeline → Annotated video: writes video
src/cat_pose_pipeline.py - Frame pipeline → Frame JSON: writes records
src/cat_pose_pipeline.py - Video analyst → Labeled pose data: labels examples
README.md - Labeled pose data → Annotation conversion: converts labels
README.md - Annotation conversion → Dataset preparation: prepares data
README.md - Dataset preparation → Pose model training: supplies dataset
README.md - Dataset preparation → Detector training: supplies dataset
README.md - Pose model training → Model configurations: trains pose model
README.md - Detector training → Model configurations: trains detector
README.md