v2.0.0
Loading...
Searching...
No Matches
ml_trainer.cpp
Go to the documentation of this file.
1//=============================================================================================================
34
35//=============================================================================================================
36// INCLUDES
37//=============================================================================================================
38
39#include "ml_trainer.h"
40
41#ifndef WASMBUILD // QProcess (used by PythonRunner) is not available in Qt WASM
42
43//=============================================================================================================
44// QT INCLUDES
45//=============================================================================================================
46
47#include <QDebug>
48
49//=============================================================================================================
50// USED NAMESPACES
51//=============================================================================================================
52
53using namespace MLLIB;
54using namespace UTILSLIB;
55
56//=============================================================================================================
57// DEFINE MEMBER METHODS
58//=============================================================================================================
59
61 : m_runner()
62{
63}
64
65//=============================================================================================================
66
68 : m_runner(config)
69{
70}
71
72//=============================================================================================================
73
75{
76 return m_runner;
77}
78
79//=============================================================================================================
80
81PythonRunnerResult MLTrainer::run(const QString& scriptPath,
82 const QStringList& args)
83{
84 if (!m_runner.isPythonAvailable()) {
85 PythonRunnerResult result;
86 result.stdErr = QStringLiteral("Python interpreter not found: ") + m_runner.config().pythonExe;
87 qWarning() << "[MLTrainer]" << result.stdErr;
88 return result;
89 }
90
91 qDebug() << "[MLTrainer] Running training script:" << scriptPath;
92
93 // If a venv is configured, use runInVenv (creates venv + installs deps automatically)
94 if (!m_runner.config().venvDir.isEmpty()) {
95 return m_runner.runInVenv(scriptPath, args);
96 }
97
98 return m_runner.run(scriptPath, args);
99}
100
101//=============================================================================================================
102
103QStringList MLTrainer::checkPrerequisites(const QStringList& packages) const
104{
105 QStringList missing;
106 for (const QString& pkg : packages) {
107 if (!m_runner.isPackageAvailable(pkg)) {
108 missing << pkg;
109 }
110 }
111 if (!missing.isEmpty()) {
112 qWarning() << "[MLTrainer] Missing Python packages:" << missing.join(QStringLiteral(", "));
113 }
114 return missing;
115}
116
117#endif // WASMBUILD
MLTrainer class declaration — ML-specific convenience wrapper over PythonRunner.
Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).
Machine learning (models, pipelines, ONNX Runtime integration).
UTILSLIB::PythonRunner & runner()
QStringList checkPrerequisites(const QStringList &packages) const
UTILSLIB::PythonRunnerResult run(const QString &scriptPath, const QStringList &args={})
Script execution result container.
Script execution configuration.
Python script launcher with logging and progress support.