Segmentation Utility intended for segmenting medical images with ease. The application is based on PyQT 5.15 and contains two windows, where the user can pick from:
ui.selection_ui
shows the segmentation annotations already made side by side with a notes field to
track changes and give alteration options
ui.label_ui
is a UI inspired by
labelme with improved functionality.
This includes performance fixes, an altered structure and more readable code. Additionally, the drawing of shapes
is refined as well as the saving. This includes saving into an SQL database.
Both files are called by their respective main function, which connects the UI elements with real functionality
(src.label_main
, src.viewer_main
). Alternatively, the src.selection_main
can be called, which opens a dialog
where one can pick between the aforementioned main GUI.
conda create --name=<your_env_name> python=3.8
conda activate <your_env_name>
pip install pyqt5 # pyqt5 can be installed via pip on python3
pip install seg_utils
The repository requires both PyQt5
and opencv-python
. There might be a conflict within the base version of PyQt5
and its binaries that ship with Linux leading to the following error
QObject::moveToThread: Current thread (0x557c88f2ec90) is not the object's thread (0x557c8970c830).
Cannot move to target thread (0x557c88f2ec90)
This can be fixed by building opencv-python
from source as described here
conda activate <your_env_name>
pip install --no-binary opencv-python opencv-python
Make sure, your database is composed similarly to the one specified in utils.database
specified in the following in
shortened notation:
# 'videos' table with the original (relative) video path, the (relative) path of the converted vide
# and the duration in ms of the video
""" video_id INTEGER, origin_path TEXT, conv_path TEXT, duration"""
# 'images' table with the (relative) video path of the extracted image, the (relative) path of the extracted image,
# and the frame number of said image
""" image_id INTEGER, video_path TEXT, image_path TEXT, frame_num INTEGER"""
# 'labels' table with the (relative) image path, a binary object containing all labels as a list of dicts and N classes
# of respective labels, i.e. class_tumour
""" label_id INTEGER, image_path TEXT, label_list"""
Make sure your folder structure is similar to following as the database is dependent on the labeled output folders,
which are set manually. Therefore, have at least the folder SegmentationClassVisualization
directly underneath the database:
│ database.db
├── converted
│ ├── video_0001.mp4
│ │ .
│ │ .
│ │ .
│ ├── video_XXXX.mp4
├── images
│ ├── video_0001_0001.png
│ │ .
│ │ .
│ │ .
│ ├── video_XXXX_XXXX.png
├── labels
│ ├── class_names.txt
│ ├── PNGImages
│ │ ├── video0001_0001.png
│ │ │ .
│ │ │ .
│ │ │ .
│ │ ├── video_XXXX_XXXX.png
│ ├── SegmentationClassVisualization
│ │ ├── video0001_0001.png
│ │ │ .
│ │ │ .
│ │ │ .
│ │ ├── video_XXXX_XXXX.png
# navigate to the base folder seg_utils containing setup.py
pip install .
pip install pyinstaller
pyinstaller labelme.spec
This creates a folder dist
, where an executable can be found.
# conda environment needs to be active otherwise there will not be a pyuic5 command
pyuic5 --from-imports=<Package_Name> -x <UI_File>.ui -o <UI_File>.py # specifiy the name given by <UI_File>
# and the import statement <Package_Name> as one would in Python with the full path to the package
# e.g. seg_utils.src
pyrcc5 <Resource_File>.qrc -o <Resource_File>_rc.py
This repo is inspired by labelme.