Making it installabel package and switching to segmentation mode

This commit is contained in:
2025-12-05 15:51:16 +02:00
parent 9011276584
commit 310e0b2285
20 changed files with 667 additions and 56 deletions

View File

@@ -1,6 +1,6 @@
# Microscopy Object Detection Application
A desktop application for detecting organelles and membrane branching structures in microscopy images using YOLOv8, featuring comprehensive training, validation, and visualization capabilities.
A desktop application for detecting and segmenting organelles and membrane branching structures in microscopy images using YOLOv8-seg, featuring comprehensive training, validation, and visualization capabilities with pixel-accurate segmentation masks.
![Python](https://img.shields.io/badge/python-3.8+-blue.svg)
![PySide6](https://img.shields.io/badge/PySide6-6.5+-green.svg)
@@ -8,8 +8,8 @@ A desktop application for detecting organelles and membrane branching structures
## Features
- **🎯 Object Detection**: Real-time and batch detection of microscopy objects
- **🎓 Model Training**: Fine-tune YOLOv8s on custom microscopy datasets
- **🎯 Object Detection & Segmentation**: Real-time and batch detection with pixel-accurate segmentation masks
- **🎓 Model Training**: Fine-tune YOLOv8s-seg on custom microscopy datasets
- **📊 Validation & Metrics**: Comprehensive model validation with visualization
- **💾 Database Storage**: SQLite database for detection results and metadata
- **📈 Visualization**: Interactive plots and charts using pyqtgraph
@@ -34,14 +34,24 @@ A desktop application for detecting organelles and membrane branching structures
## Installation
### 1. Clone the Repository
### Option 1: Install from PyPI (Recommended)
```bash
pip install microscopy-object-detection
```
This will install the package and all its dependencies.
### Option 2: Install from Source
#### 1. Clone the Repository
```bash
git clone <repository-url>
cd object_detection
```
### 2. Create Virtual Environment
#### 2. Create Virtual Environment
```bash
# Linux/Mac
@@ -53,25 +63,44 @@ python -m venv venv
venv\Scripts\activate
```
### 3. Install Dependencies
#### 3. Install in Development Mode
```bash
pip install -r requirements.txt
# Install in editable mode with dev dependencies
pip install -e ".[dev]"
# Or install just the package
pip install .
```
### 4. Download Base Model
The application will automatically download the YOLOv8s.pt model on first use, or you can download it manually:
The application will automatically download the YOLOv8s-seg.pt segmentation model on first use, or you can download it manually:
```bash
# The model will be downloaded automatically by ultralytics
# Or download manually from: https://github.com/ultralytics/assets/releases
```
**Note:** YOLOv8s-seg is a segmentation model that provides pixel-accurate masks for detected objects, enabling more precise analysis than standard bounding box detection.
## Quick Start
### 1. Launch the Application
After installation, you can launch the application in two ways:
**Using the GUI launcher:**
```bash
microscopy-detect-gui
```
**Or using Python directly:**
```bash
python -m microscopy_object_detection
```
**If installed from source:**
```bash
python main.py
```
@@ -85,11 +114,12 @@ python main.py
### 3. Perform Detection
1. Navigate to the **Detection** tab
2. Select a model (default: yolov8s.pt)
2. Select a model (default: yolov8s-seg.pt)
3. Choose an image or folder
4. Set confidence threshold
5. Click **Detect**
6. View results and save to database
6. View results with segmentation masks overlaid
7. Save results to database
### 4. Train Custom Model
@@ -212,8 +242,8 @@ The application uses SQLite with the following main tables:
- **models**: Stores trained model information and metrics
- **images**: Stores image metadata and paths
- **detections**: Stores detection results with bounding boxes
- **annotations**: Stores manual annotations (future feature)
- **detections**: Stores detection results with bounding boxes and segmentation masks (polygon coordinates)
- **annotations**: Stores manual annotations with optional segmentation masks (future feature)
See [`ARCHITECTURE.md`](ARCHITECTURE.md) for detailed schema information.
@@ -230,7 +260,7 @@ image_repository:
allowed_extensions: [".jpg", ".jpeg", ".png", ".tif", ".tiff"]
models:
default_base_model: "yolov8s.pt"
default_base_model: "yolov8s-seg.pt"
models_directory: "data/models"
training:
@@ -258,7 +288,7 @@ visualization:
from src.model.yolo_wrapper import YOLOWrapper
# Initialize wrapper
yolo = YOLOWrapper("yolov8s.pt")
yolo = YOLOWrapper("yolov8s-seg.pt")
# Train model
results = yolo.train(
@@ -393,10 +423,10 @@ make html
**Issue**: Model not found error
**Solution**: Ensure YOLOv8s.pt is downloaded. Run:
**Solution**: Ensure YOLOv8s-seg.pt is downloaded. Run:
```python
from ultralytics import YOLO
model = YOLO('yolov8s.pt') # Will auto-download
model = YOLO('yolov8s-seg.pt') # Will auto-download
```