Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
944b510
wip put backends into separate files
saeugetier Jun 16, 2025
8d6f417
outsource utils into header
saeugetier Jun 20, 2025
2d7939e
wip implementation of ncnn segmentation
saeugetier Jun 20, 2025
88e3111
wip backend
saeugetier Jun 20, 2025
b7537ee
intermediate state of the ncnn implementation
saeugetier Jun 24, 2025
f16c15f
work without pointers
saeugetier Jun 24, 2025
3bf9f16
correct inference implementation
saeugetier Jul 19, 2025
7cfca22
add debug output
saeugetier Jul 19, 2025
829abd5
remove backend implementations
saeugetier Jul 19, 2025
2504340
adjust project file
saeugetier Jul 19, 2025
eca3c65
install model files
saeugetier Jul 20, 2025
efd107d
install model files
saeugetier Jul 20, 2025
fce7785
adjust project to renamed files
saeugetier Jul 20, 2025
a464a80
add new neural network runtime to settings menu form
saeugetier Jul 20, 2025
14256eb
include models folder in order to get the coco.names file into app/share
saeugetier Jul 20, 2025
5643981
rename class
saeugetier Jul 20, 2025
583c38f
introduce base class for segmentation
saeugetier Jul 20, 2025
3bf3d9d
use only single file
saeugetier Jul 20, 2025
5b6281e
add script file for downloading models
saeugetier Jul 20, 2025
f8ae54d
adjust dependency
saeugetier Jul 20, 2025
72c834c
exclude files in gitignore
saeugetier Jul 20, 2025
a2c651f
export symbol
saeugetier Jul 20, 2025
becd140
remove draw segmentation function from onnx implementation
saeugetier Jul 21, 2025
fc02b59
ressource load implementation
saeugetier Jul 21, 2025
8f280f2
introduce property for changing the neural network
saeugetier Jul 21, 2025
977b7df
add debug info
saeugetier Jul 21, 2025
353a575
adjust build information
Jul 22, 2025
363bf17
remove compiled in yolo model
Jul 22, 2025
aca33cb
make runtime selectable
Jul 22, 2025
bad6418
fix model loading
Jul 22, 2025
f96353d
correct property name
saeugetier Jul 22, 2025
d7d5199
add connection
saeugetier Jul 22, 2025
1c0f085
remove obsolete load
saeugetier Jul 22, 2025
f9815d3
fix assignment
saeugetier Jul 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ flatpak/build-dir
flatpak/repo
flatpak/.flatpak-builder
*.user
models/*.bin
models/*.param
logs
53 changes: 52 additions & 1 deletion io.github.saeugetier.photobooth.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
],
"cleanup": [
"/bin/*",
"/share/opencv4/*"
"/share/*"
]
},
{
Expand Down Expand Up @@ -75,6 +75,25 @@
}
]
},
{
"name": "ncnn",
"buildsystem": "cmake-ninja",
"builddir": true,
"config-opts": [
"-DNCNN_BUILD_TESTS=OFF",
"-DNCNN_BUILD_EXAMPLES=OFF",
"-DNCNN_BUILD_TOOLS=OFF",
"-DNCNN_BUILD_BENCHMARK=OFF",
"-DNCNN_SHARED_LIB=ON"
],
"sources": [
{
"type": "archive",
"url": "https://github.com/Tencent/ncnn/archive/refs/tags/20250503.tar.gz",
"sha256": "3afea4cf092ce97d06305b72c6affbcfb3530f536ae8e81a4f22007d82b729e9"
}
]
},
{
"name": "qtvirtualkeyboard",
"buildsystem": "cmake-ninja",
Expand All @@ -92,6 +111,38 @@
"rmdir ${FLATPAK_DEST}/lib/${FLATPAK_ARCH}-linux-gnu"
]
},
{
"name": "yolo-models",
"buildsystem": "simple",
"build-options": {
"build-args": [
"--share=network"
]
},
"build-commands": [
"python3 -m venv yolo-venv",
". yolo-venv/bin/activate && pip install --no-cache-dir numpy==1.26.4",
". yolo-venv/bin/activate && pip install --no-cache-dir torch==2.4.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu",
". yolo-venv/bin/activate && pip install --no-cache-dir ultralytics==8.3.168 onnxruntime onnx==1.16.1 onnxslim==0.1.59 ncnn==1.0.20250503 rknn-toolkit2==2.3.2",
". yolo-venv/bin/activate && yolo export model=yolo11n-seg.pt format=onnx",
". yolo-venv/bin/activate && yolo export model=yolo11x-seg.pt format=onnx",
". yolo-venv/bin/activate && yolo export model=yolo11n-seg.pt format=ncnn",
". yolo-venv/bin/activate && yolo export model=yolo11x-seg.pt format=ncnn",
"rm -rf yolo-venv"
],
"post-install": [
"rm *.pt",
"rm *.torchscript",
"mkdir ${FLATPAK_DEST}/share/models",
"mv * ${FLATPAK_DEST}/share/models"
],
"sources": [
{
"type": "file",
"path": "models/coco.names"
}
]
},
{
"name": "qtbooth",
"buildsystem": "qmake",
Expand Down
5 changes: 5 additions & 0 deletions io.github.saeugetier.photobooth.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
</screenshots>

<releases>
<release version="0.7.1" date="2025-07-22">
<description translate="no">
<p>NCNN as secondary neural network runtime for accelerated execution on Raspberry Pi. Several bugfixes for better user experience with flatpak build.</p>
</description>
</release>
<release version="0.7.0" date="2025-05-25">
<description translate="no">
<p>Initial release with flatpak. New implementation of background removal filter. Port from Qt5 to Qt6.</p>
Expand Down
13 changes: 13 additions & 0 deletions models/scripts/download_export_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from ultralytics import YOLO

# Load a model
model_n = YOLO("yolo11n-seg.pt") # load an official model
model_x = YOLO("yolo11x-seg.pt") # load an official model

# Export the model
model_n.export(format="onnx")
model_n.export(format="ncnn")

model_x.export(format="onnx")
model_x.export(format="ncnn")

8 changes: 8 additions & 0 deletions qml/Application.qml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ ApplicationWindow {
console.log("Camera orientation changed to: " + applicationSettings.cameraOrientation)
}

settingsMenu.comboBoxNeuralNetworkRuntime.onCurrentValueChanged:
{
applicationSettings.neuralNetworkRuntime = String(settingsMenu.comboBoxNeuralNetworkRuntime.currentValue)
console.log("Neural network runtime changed to: " + applicationSettings.neuralNetworkRuntime)
}

mainMenu.printerBusy: printer ? printer.busy : false
}

Expand All @@ -174,6 +180,7 @@ ApplicationWindow {
property bool printFromGallery: true
property bool enableSettingsPassword: true
property int cameraOrientation: 0
property string neuralNetworkRuntime: "ONNX"

Component.onCompleted:
{
Expand All @@ -190,6 +197,7 @@ ApplicationWindow {
flow.collageMenu.multiplePrints = multiplePrints
flow.snapshotMenu.hideSnapshotSettingsPane = disableSnapshotSettingsPane
flow.imagePreview.effectButton.visible = !disableEffectPopup
flow.settingsMenu.comboBoxNeuralNetworkRuntime.currentIndex = flow.settingsMenu.comboBoxNeuralNetworkRuntime.indexOfValue(neuralNetworkRuntime)
}

onPrinterNameChanged:
Expand Down
22 changes: 22 additions & 0 deletions qml/SettingsMenuForm.ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Item {
property alias switchEnableSettingsPassword: switchEnableSettingsPassword
property alias versionText: labelVersionText.text
property alias comboBoxCameraOrientation: comboBoxCameraOrientation
property alias comboBoxNeuralNetworkRuntime: comboBoxNeuralNetworkRuntime

ColumnLayout {
anchors.fill: parent
Expand Down Expand Up @@ -191,6 +192,27 @@ Item {
}]
}
}

RowLayout
{
spacing: 10
Label
{
text: qsTr("Neuroal Network Runtime")
}
Item
{
Layout.fillWidth: true
}
ComboBox
{
id: comboBoxNeuralNetworkRuntime
textRole: "text"
valueRole: "value"
model: [{text: "ONNX Runtime", value: "ONNX"}, {text: "NCNN Runtime", value: "NCNN"}]
Layout.preferredWidth: 200
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions qml/SnapshotMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ SnapshotMenuForm {
cameraRenderer.backgroundFilter.method: snapshotSettings.backgroundFilterEnabled ? (snapshotSettings.chromaKeyEnabled ? "Chroma" : "Neural") : "None"
cameraRenderer.backgroundFilterEnabled: snapshotSettings.backgroundFilterEnabled
cameraRenderer.backgroundFilter.keyColor: snapshotSettings.chromaKeyColor
cameraRenderer.backgroundFilter.neuralNetworkRuntime: applicationSettings.neuralNetworkRuntime
cameraRenderer.backgroundImage: snapshotSettings.backgroundImage

SequentialAnimation
Expand Down
15 changes: 10 additions & 5 deletions qtbooth.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ SOURCES += src/collageiconmodel.cpp \
src/noprinter.cpp \
src/printerfactory.cpp \
src/replacebackgroundvideofilter.cpp \
src/segmentation.cpp \
src/selphyprinter.cpp \
src/standardprinter.cpp \
src/system.cpp \
src/translationhelper.cpp \
src/yolo11seg.cpp
src/yolo11segncnn.cpp \
src/yolo11segonnx.cpp

RESOURCES += qml.qrc \
yolomodel.large.qrc \
yolomodel.small.qrc
RESOURCES += qml.qrc

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
Expand All @@ -52,6 +52,7 @@ DISTFILES += \

INCLUDEPATH += src/ \
libs/onnxruntime/include/ \
libs/ncnn/include/ \

HEADERS += \
src/abstractprinter.h \
Expand All @@ -67,11 +68,14 @@ HEADERS += \
src/noprinter.h \
src/printerfactory.h \
src/replacebackgroundvideofilter.h \
src/segmentation.h \
src/selphyprinter.h \
src/standardprinter.h \
src/system.h \
src/translationhelper.h \
src/yolo11seg.h
src/yolo11segncnn.h \
src/yolo11segonnx.h \
src/yolobackend.h

contains(ANDROID_TARGET_ARCH,x86) {
ANDROID_PACKAGE_SOURCE_DIR = \
Expand All @@ -81,6 +85,7 @@ contains(ANDROID_TARGET_ARCH,x86) {
DEFINES += GIT_CURRENT_SHA1="$(shell git -C \""$$_PRO_FILE_PWD_"\" describe)"

LIBS += -L"$$PWD/libs/onnxruntime/lib" -lonnxruntime
LIBS += -L"$$PWD/libs/ncnn/lib" -lncnn

!isEmpty(PREFIX) {
INSTALLS += target
Expand Down
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ int main(int argc, char *argv[])
if (QFontDatabase::addApplicationFont(":/font/DejaVuSerif/DejaVuSerif.ttf") == -1)
qWarning() << "Failed to load DejaVuSerif.ttf";

qDebug() << "Standard path: " << QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
qDebug() << "Standard path: " << QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);

qmlRegisterType<CollageModelFactory>("CollageModel", 1, 0, "CollageModelFactory");
qmlRegisterUncreatableType<CollageIconModel>("CollageModel", 1, 0, "CollageIconModel", "CollageIconModel can only be created via CollageModeFactory");
qmlRegisterUncreatableType<CollageImageModel>("CollageModel", 1, 0, "CollageImageModel", "CollageImageModel can only be created via CollageModeFactory");
Expand Down
Loading