Skip to content

Develop a real-time ML system to automatically classify Charpy test specimens into 10 categories (10% to 100% shear fracture appearance)

Notifications You must be signed in to change notification settings

ilegault/MLMCSC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MLMCSC - Machine Learning Material Charpy Specimen Classification

A machine learning system for analyzing Charpy impact test specimens, featuring automated fracture surface detection, shear percentage prediction, and human-in-the-loop continuous learning.

Features

  • YOLO Object Detection: Automatic detection of Charpy specimens in images
  • Shear Percentage Prediction: ML-based regression model for shear analysis
  • Lateral Expansion Measurement: Physical measurement capabilities with calibration
  • Web Interface: User-friendly interface for image upload and analysis
  • Human-in-the-Loop Labeling: Technician feedback system for model improvement
  • Online Learning: Continuous model retraining from user corrections
  • Performance Monitoring: Real-time metrics tracking (MAE, RMSE, R²)

Project Structure

MLMCSC/
├── src/
│   ├── mlmcsc/          # Core ML package (detection, classification, measurement)
│   ├── web/             # Web interface (FastAPI, database, online learning)
│   ├── apps/            # Training and analysis applications
│   └── camera/          # Camera interface and calibration
├── data/                # Datasets and calibration files
├── models/              # Trained models (YOLO, classification)
├── docs/                # Documentation and guides
├── tests/               # Test suite
├── tools/               # Utility scripts
├── app.py               # Main application entry point
└── requirements.txt     # Dependencies

Installation

Prerequisites

  • Python 3.8+
  • CUDA-compatible GPU (optional, for training)

Setup

# Clone the repository
git clone https://github.com/yourusername/MLMCSC.git
cd MLMCSC

# Install dependencies
pip install -r requirements.txt

Quick Start

Web Interface (Primary Method)

# Start the application
python app.py

The application will:

  • Launch the web server on port 8000
  • Automatically open your browser to http://localhost:8000
  • Provide an interactive interface for image analysis and labeling

Web Interface Features

  • Upload Charpy specimen images
  • View YOLO detection results with bounding boxes
  • Get shear percentage predictions
  • Provide technician corrections for continuous learning
  • Monitor model performance metrics
  • Export labeling history

Configuration

Edit config/config.yaml to customize:

app:
  host: "0.0.0.0"
  port: 8000

models:
  yolo_model_path: "models/detection/best.pt"
  classification_model_path: "models/classification/charpy_shear_regressor.pkl"

online_learning:
  enabled: true
  update_threshold: 10  # Number of labels before retraining

API Endpoints

The web interface provides a REST API for integration:

  • POST /predict - Analyze uploaded image and return predictions
  • POST /submit_label - Submit technician corrections for training
  • GET /get_metrics - Retrieve model performance metrics
  • GET /get_history - Get labeling history with pagination
  • GET /export_history - Export complete history as CSV
  • GET /health - Health check endpoint

For detailed API documentation, see src/web/README.md.

Development

Training Models

Train a new YOLO detection model:

python src/apps/trainer/train_specimen_detector.py --data data/raw/charpy_dataset

Train a new classification model:

python src/apps/trainer/main_shiny_trainer.py --data data/processed/shiny_training_data

Using Python API

# Detection
from src.models.object_detector import ObjectDetector
detector = ObjectDetector("models/detection/best.pt")
detections = detector.detect(image)

# Classification
from src.mlmcsc.regression import ShinyRegionBasedClassifier
classifier = ShinyRegionBasedClassifier()
classifier.load_model("models/classification/charpy_shear_regressor.pkl")
result = classifier.predict(image)

Running Tests

pytest tests/

Documentation

System Architecture

How It Works

  1. Image Upload: Technician uploads Charpy specimen image via web interface
  2. Detection: YOLO model locates the specimen in the image
  3. Feature Extraction: Analyzes shear characteristics and physical properties
  4. Prediction: Regression model predicts shear percentage
  5. Human Review: Technician reviews and corrects prediction if needed
  6. Online Learning: System retrains model periodically with new labeled data
  7. Metrics Tracking: Performance metrics (MAE, RMSE) continuously monitored

Key Components

  • YOLO Detection: Pre-trained object detector for specimen localization
  • Shear Classifier: Regression model for shear percentage prediction
  • Online Learning System: Automated model retraining pipeline
  • Web Interface: FastAPI backend with responsive frontend
  • Database: SQLite for predictions, labels, and metrics storage

License

This project is licensed under the MIT License.

Acknowledgments

  • YOLOv8 (Ultralytics) for object detection
  • scikit-learn for ML utilities
  • FastAPI for web framework

Version 2.0 - Clean architecture with human-in-the-loop learning

About

Develop a real-time ML system to automatically classify Charpy test specimens into 10 categories (10% to 100% shear fracture appearance)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •