python - 有没有办法中断训练过程?
问题描述
我是OpenCV的新手,我想使用python模块 ( opencv-python
) 训练我的模型。
这是我的代码:
def startTraining():
trainingThread = Thread(target=trainModel, args=())
def trainModel():
# some code to get the faces and the ids
recognizer.train(faces, np.array(ids))
def stopTraining()
# some code to kill the training process
而且效果很好。
所以这是我的问题:有没有办法中断这个过程(杀死它,停止它......)?
之后我不需要能够重新启动该过程......我不知道如何使用threading来做到这一点。我想创建一个函数来终止进程。(例子)
任何帮助都是有用的,谢谢。
解决方案
推荐阅读
- python - 将下载的 Python 的路径添加到 Visual Studio Code
- python - 在 Windows 10 上运行软件时禁用通知
- python - 合并日期上具有不同值的多个数据框
- r - 有没有办法增加系统发育树中允许的物种数量以供我分析?
- bioconductor - clusterProfiler 无法加载包
- google-apps-script - 创建自定义函数以通过 App 脚本验证 Google 电子表格中的数据
- linker-errors - 链接错误 libbfd:在 RHEL8(64 位)上构建 32 位应用程序时
- javascript - Javascript:操作数组以返回最短节点
- javascript - 在鼠标悬停时显示名称
- python - 可迭代和迭代器