Skip to content

Ru-Na8/Project_in_data_intensive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MLflow Model Registry Application

Python FastAPI Vue.js MLflow Node.js npm TensorFlow

A comprehensive full-stack machine learning application featuring pose detection, exercise analysis, and performance scoring. The system uses models registered in MLflow for expert score prediction, weakest link classification, and real-time squat form analysis through pose estimation.

Note: For an in-depth explanation of our system architecture, coding conventions, testing strategies, API design, security practices, and development workflow, please refer to our GitLab Wiki (out dated):
Design-and-Coding-Rules-Summary


πŸš€ Quick Start

# 1. Start MLflow Server
mlflow server --host 127.0.0.1 --port 4800

# 2. Set up Backend
cd backend
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt
python src/app.py

# 3. Set up Frontend
cd frontend
npm install
npm run build
npm run preview

Visit:


πŸ“‹ Requirements

Backend

  • Python 3.11
  • Key dependencies (all included in requirements.txt):
    • FastAPI 0.115.8
    • MLflow 2.20.3
    • uvicorn 0.34.0
    • python-multipart 0.0.20
    • TensorFlow 2.19.0
    • Keras 3.9.2
    • pandas 2.2.3
    • joblib 1.4.2
    • aiofiles 23.2.1

Frontend

  • Node.js 22.13.1
  • npm 10.9.2
  • Vue.js 3.5.13
  • Key dependencies:
    • @tensorflow/tfjs 4.13.0
    • @tensorflow-models/pose-detection 1.0.0
    • three.js 0.176.0
    • axios 1.7.9
    • pinia 2.3.1

πŸ”§ Detailed Setup

MLflow Configuration

The MLflow server needs to be running before starting the application:

mlflow server --host 127.0.0.1 --port 4800

Configuration in config.py:

MLFLOW_URI = "http://127.0.0.1:4800"
EXPERT_SCORE_CHAMPION = "models:/ChampionModel@expert_score_champion"
WEAKEST_LINK_CHAMPION = "models:/ChampionModel@weakest_link_champion"
POSE_TRANSFORMER_URI = "models:/PoseCoordinateTransformer@coordinate_transformer_champion"
DEPTH_ESTIMATOR_URI = "models:/PoseDepthEstimator@depth_estimator_champion"
SEQUENCE_DETECTOR_URI = "models:/SquatSequenceDetector@sequence_detector_champion"
FORM_CLASSIFIER_URI = "models:/SquatFormClassifier@form_classifier_champion"
PERFORMANCE_SCORER_URI = "models:/SquatPerformanceScorer@performance_scorer_champion"

Backend Setup

  1. Create and activate virtual environment:
    cd backend
    python -m venv venv
    source venv/bin/activate  # Windows: venv\Scripts\activate
  2. Install dependencies:
    pip install -r requirements.txt
  3. Start the FastAPI server:
    uvicorn main:app --host 0.0.0.0 --port 5000

Frontend Setup

  1. Install dependencies:
    cd frontend
    npm install
  2. Start development server:
    npm run dev  # Development mode
    # or
    npm run build && npm run preview  # Production mode

Project Structure

Project_in_data_intensive/
β”œβ”€β”€ backend/                 # FastAPI backend application
β”‚   β”œβ”€β”€ src/                # Source code
β”‚   β”‚   β”œβ”€β”€ app.py         # Main application entry point
β”‚   β”‚   β”œβ”€β”€ config.py      # Configuration and model URIs
β”‚   β”‚   β”œβ”€β”€ controllers/   # API route controllers
β”‚   β”‚   β”œβ”€β”€ services/      # Business logic services
β”‚   β”‚   β”œβ”€β”€ schemas/       # Pydantic data models
β”‚   β”‚   β”œβ”€β”€ utils/         # Utility functions and scalers
β”‚   β”‚   └── tests/         # Unit and integration tests
β”‚   β”œβ”€β”€ requirements.txt   # Python dependencies
β”‚   └── pyproject.toml    # Project configuration
β”œβ”€β”€ frontend/               # Vue.js frontend application
β”‚   β”œβ”€β”€ src/               # Source code
β”‚   β”‚   β”œβ”€β”€ components/    # Vue components
β”‚   β”‚   β”œβ”€β”€ views/         # Page views
β”‚   β”‚   β”œβ”€β”€ services/      # API services
β”‚   β”‚   └── router/        # Application routing
β”‚   β”œβ”€β”€ public/            # Static assets and 3D models
β”‚   └── package.json       # Node.js dependencies
β”œβ”€β”€ ML/                     # Machine learning experiments
β”‚   β”œβ”€β”€ classification/    # Classification models notebooks
β”‚   β”œβ”€β”€ linearregression/  # Regression models notebooks
β”‚   └── deeplearning/      # Deep learning models notebooks
β”œβ”€β”€ reports/                # Assignment reports
└── training_data/          # Pose data storage

Jupyter Notebook Integration

Set MLflow tracking URI in your notebooks:

import mlflow
mlflow.set_tracking_uri("http://127.0.0.1:4800")

πŸ” Verification

  1. MLflow UI should be accessible at http://127.0.0.1:4800
  2. Backend API should be accessible at http://localhost:5000
  3. Frontend should be accessible at http://localhost:4173 (production) or http://localhost:5173 (development)

API Endpoints

The backend provides the following main endpoints:

  • POST /api/v1/expert-score/predict - Expert score prediction
  • POST /api/v1/weakest-link/predict - Weakest link classification
  • POST /api/v1/pose/upload - Pose data upload and analysis
  • GET /api/v1/pose/sessions - List pose analysis sessions
  • GET /api/v1/pose/sessions/{session_id}/feedback - Get comprehensive feedback

πŸ—οΈ Architecture Overview

Backend Services Architecture

The backend follows a service-oriented architecture with the following key services:

  1. Core ML Services

    • LinearRegressionService: Expert score predictions
    • ClassificationService: Weakest link classification
  2. Pose Analysis Pipeline

    • KeypointStorageService: Pose data persistence
    • FeatureEngineeringService: Biomechanical feature extraction
    • ExerciseDetectionService: Squat sequence identification
    • Pose2Dto3DService: 2D to 3D coordinate transformation
    • SquatFormClassificationService: Form quality assessment
    • SquatPerformanceScoringService: Performance quantification
    • SquatFeedbackService: Comprehensive feedback generation
    • PoseOrchestratorService: Central coordination hub
  3. Controllers

    • RegressionController: Handles regression prediction requests
    • ClassificationController: Manages classification requests
    • PoseController: Orchestrates pose analysis workflows

πŸ›  Troubleshooting

Common Issues

  1. Port Conflicts

    • Ensure ports 4800, 5000, and 4173 are available.
    • Check for other services using these ports.
  2. MLflow Connection Issues

    • Verify the MLflow server is running.
    • Check URI configuration in config.py.
    • Ensure consistent URIs across all components.
  3. Backend Issues

    • Verify all dependencies are installed.
    • Check Python version compatibility.
    • Ensure the virtual environment is activated.
  4. Frontend Issues

    • Clear npm cache if needed:
      npm cache clean --force
      Remove-Item -Recurse -Force node_modules
      npm install
    • Check URI configuration in config.js.
  5. Model Loading Issues

    • Verify all required models are registered in MLflow
    • Check model aliases are correctly set
    • Ensure scaler files exist in backend/src/utils/ directory
    • Make sure text and text are present during dev with the required models
  6. Pose Detection Issues

    • Verify TensorFlow.js models are properly loaded
    • Check camera permissions in browser
    • Ensure sufficient lighting for pose detection

πŸ“ Development Notes

  • MLflow Server: Must remain running during development.
  • Backend Dependency: Ensure the virtual environment is activated before running commands.
  • Frontend: If issues arise, clear the npm cache or reinstall dependencies.
  • For additional details on coding standards, linters and development workflow, please check our GitLab Wiki:
    Design-and-Coding-Rules-Summary

🀝 Contributing

For detailed guidelines on commit message conventions, branch naming, and versioning, please refer to our GitLab Wiki:
Design-and-Coding-Rules-Summary


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6