Micro Fiber Detection in Sludge

Detect, count & analyze microfibres in wastewater sludge — fast.

MicroFiberDetect is a desktop application powered by deep learning (Mask R‑CNN) that detects microfibres in microscope images, estimates their length via skeletonization, and derives dominant colour using clustering. Built for environmental researchers and lab practitioners.

Detected fibres with bounding boxes
Colour clustering result
Length estimation via skeletonization

Table of Contents

Project Description

This project contains an application designed to detect microfibres in sludge. It uses a fine‑tuned Mask R‑CNN for instance segmentation, k‑means clustering in HSL space for colour estimation, and skeletonized masks for length measurement.

Python PyQt6 / PySide6 OpenCV Torch / Torchvision NumPy / scikit-image CUDA (optional)

Repository Structure

Utils/
images/                # Contains all images used in the app
models/                # TorchScript files for both CA and Glass models
modules/               # Core code modules
test_data/             # Sample images extracted from glass filter
themes/                # App stylesheet
widgets/               # Reusable UI widgets
main.py                # App entrypoint
main.ui                # Qt Designer UI file

Installation

Prerequisites

  • Python 3
  • OpenCV
  • PySide6 / PyQt6
  • pyinstaller (for building executables)
  • torch & torchvision
  • numpy
  • scikit-image

Run from Source

  1. Install prerequisites (e.g., pip install -r requirements.txt).
  2. Launch the app with python main.py.

Note: ensure model files are present in models/.

Windows Build

Download the packaged app:

Download ZIP

Windows Defender may warn you. Click More infoRun anyway.

Usage

  1. Choose the correct model for your filter type: Glass or Cellulose Acetate (CA).
  2. Set the scale to match your microscope magnification.
  3. Load images or a folder of samples; processing progress is displayed.
  4. Review per‑image results: fibre count, confidence, colour and length (μm).
  5. Export the results table to CSV and save images with overlayed bounding boxes.

Features

✔ Implemented

Windows build
CA & Glass filter detection models
Image processing pipeline
Progress bar for batch processing
Overlay bounding boxes on detected fibres
Total & per‑image fibre count
Length measurement at defined scale
Dominant colour via K‑means clustering
Export table data (CSV) & images with overlays
Home page explanation of app
CUDA support

❌ Planned

Linux build
Mac build
Export images at original resolution
Toggle segmentation / bounding boxes

Paper

Learn about the datasets (Glass & CA), model training, colour extraction, and length estimation in the accompanying paper.

MicroFiberDetect: An Application for the Detection of Microfibres in Wastewater Sludge based on CNNs
Felix Marti‑Perez, Ana Domínguez‑Rodríguez, Cèsar Ferri, Carlos Monserrat — 2025
📄 Read PDF Back to Overview

Contributing

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.

License

MIT License

Copyright (c) 2024 Felix Marti Perez

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.