A tool for detecting, segmenting, and tracking cavitation bubbles in video. Uses a YOLO-based model and the ByteTrack tracker to build trajectories and compute bubble statistics.
- Frame-by-frame bubble detection and segmentation
- Object tracking with trajectory export
- Memory-efficient tracking: bounded history window and automatic cleanup of finished trackers
- Automatic CSV reports with size and velocity per bubble
- Histograms and summary plots
- Streamlit web interface and FastAPI REST service
- Docker support (CPU and GPU)
- Experiment tracking with ClearML
- Linux
- uv — for local runs
- Docker + Docker Compose — for containerised runs
- (optional) NVIDIA GPU + NVIDIA Container Toolkit — for GPU acceleration
├── pyproject.toml # Project dependencies (uv)
├── Dockerfile # Universal image (CPU/GPU)
├── docker-compose.yml # Run without GPU
├── docker-compose.gpu.yml # Override for NVIDIA GPU
├── .env.example # Environment variables template
├── src/
│ ├── config.py # Configuration via environment variables
│ ├── api/
│ │ ├── main.py # FastAPI app factory
│ │ ├── auth.py # JWT authentication
│ │ └── video.py # Video processing endpoint
│ ├── ml/
│ │ ├── segmentation.py # YOLO segmentation logic
│ │ ├── tracking.py # ByteTrack tracker
│ │ └── processing.py # Video processing pipeline
│ └── utils/
│ ├── visualization.py # Mask drawing
│ └── geometry.py # Centroid, distance calculations
├── frontend/
│ └── streamlit_app.py # Web interface
└── scripts/
├── download_dataset.py # Download dataset from Roboflow
├── train.py # Model training with ClearML logging
├── tune.py # Hyperparameter search with ClearML logging
└── download_model.py # Download weights from Hugging Face
git clone https://github.com/your-user/cavitation_bubbles_segmentation.git
cd cavitation_bubbles_segmentationgit lfs install
git lfs pullcp .env.example .envEdit .env and fill in the values:
ROBOFLOW_API_KEY=your_key
ROBOFLOW_WORKSPACE=itmo-ai-in-chemistry
ROBOFLOW_PROJECT=cavitation_bubbles_merged
ROBOFLOW_DATASET_VERSION=1
HUGGINGFACE_TOKEN=your_token
CLEARML_WEB_HOST=https://app.your-clearml-instance.example.com
CLEARML_API_HOST=https://api.your-clearml-instance.example.com
CLEARML_FILES_HOST=https://files.your-clearml-instance.example.com
CLEARML_PROJECT=your_clearml_project
CLEARML_API_ACCESS_KEY=your_access_key
CLEARML_API_SECRET_KEY=your_secret_key
username=admin
password=your_password
fastapi_host=fastapi # use "fastapi" for Docker, "localhost" for local runs
fastapi_port=8000
streamlit_port=8501
secret_key=random_stringdocker compose up --builddocker compose -f docker-compose.yml -f docker-compose.gpu.yml up --buildOpen http://localhost:8501 to access the Streamlit interface.
curl -LsSf https://astral.sh/uv/install.sh | shuv syncfastapi_host=localhostuv run uvicorn src.api.main:app --port 8000 --reloaduv run streamlit run frontend/streamlit_app.pyOpen http://localhost:8501.
| Method | Path | Description |
|---|---|---|
POST |
/token |
Obtain a JWT token |
POST |
/process_video/ |
Process a video file |
Interactive docs available at http://localhost:8000/docs.
uv run python scripts/download_dataset.pyuv run python scripts/train.pyTraining metrics and artifacts are logged to ClearML automatically.
uv run python scripts/tune.pyuv run python scripts/download_model.pyMIT License
- Ultralytics YOLO
- ByteTrack
- Roboflow — dataset hosting
- ClearML — experiment tracking