git clone https://github.com/ragh598/grain-size-analysis-sam.git
cd grain-size-analysis-sam- Image Preprocessing: Load and resize microscopy images
- Segmentation: Meta's SAM generates grain masks
- Post-processing: Filter, clean, and validate masks
- Morphometry: Calculate area, diameter, shape factors
- Visualization: Generate annotated images and plots
- Export: Save results to CSV with comprehensive statistics
High-throughput automated grain size analysis for materials science using Meta's Segment Anything Model (SAM)
Performance: Analyzed 10,830+ grains across multiple duralumin samples
- Mean grain area: 916.4 μm²
- Processing speed: 12 images/hous on GPU T4 on Google Colab
- This was implemented with sequential image input to the model. This code can be further optimized for multi-processing.
- ~90% reduction in analysis time vs. manual methods
Manual grain size analysis in materials science is:
- Time-consuming: Hours per sample
- Subjective: Skill-dependent measurements
- Low-throughput: Limits statistical significance
This project aims to be a cost-effective alternative to manual and tedious checks for each image to check and identify the microstructure characteristics. This project automates the entire pipeline using SOTA Vision Transformer.