计算机视觉 opencv
Utilizing computer vision and machine learning to automatically detect and predict Parkinson’s disease based on geometric drawings (i.e., spirals and sign waves).
利用计算机视觉和机器学习,可以根据几何图形(即螺旋形和符号波)自动检测和预测帕金森氏病。
A 2017 study by Zham et al. found that it was possible to detect Parkinson’s by asking the patient to draw a spiral and then track:
Zham等人的2017年研究。 发现可以通过要求患者画出螺旋线然后进行跟踪来检测帕金森氏症:
Speed of drawing 绘图速度 Pen pressure 笔压The researchers found that the drawing speed was slower and the pen pressure lower among Parkinson’s patients — this was especially pronounced for patients with a more acute/advanced forms of the disease.
研究人员发现, 帕金森氏症患者的绘画速度较慢,笔压较低 -对于这种疾病的急性/晚期患者尤其如此 。
We’ll be leveraging the fact that two of the most common Parkinson’s symptoms include tremors and muscle rigidity which directly impact the visual appearance of a hand drawn spiral and wave.
我们将利用以下事实:帕金森氏症最常见的两种症状包括震颤和肌肉僵硬,这直接影响到手绘螺旋和波浪形的视觉外观。
The variation in visual appearance will enable us to train a computer vision and machine learning algorithm to automatically detect Parkinson’s disease.
视觉外观的变化将使我们能够训练计算机视觉和机器学习算法,以自动检测帕金森氏病。
The dataset itself consists of 204 images and is pre-split into a training set and a testing set, consisting of:
数据集本身包含204张图像,并被预先分为训练集和测试集,其中包括:
Spiral: 102 images, 72 training, and 30 testing
螺旋: 102张图像,72次训练和30次测试
Wave: 102 images, 72 training, and 30 testing
Wave: 102张图像,72次训练和30次测试
Here we would be applying two methods :
在这里,我们将应用两种方法:
Apply computer vision and OpenCV to detect Parkinson’s based on geometric drawings and then train a machine learning model to classify them 应用计算机视觉和OpenCV根据几何图形检测帕金森氏病,然后训练机器学习模型对其进行分类 Apply deep learning(Fastai) 应用深度学习(法泰)Output :
输出:
Validation Accuracy for Spiral images is 82%
螺旋图像的验证精度为82%
for each image in the list automatically classify the image using our new HOG + Random Forest based classifier and add color-coded annotations
对于列表中的每个图像,使用我们新的基于HOG + Random Forest的分类器对图像进行自动分类,并添加颜色编码的注释
Finally add the image list to opencv montage for visualization 最后将图像列表添加到opencv montage以进行可视化The opencv build_montages function requires three arguments:
opencv build_montages函数需要三个参数:
image_list : This parameter is a list of images loaded via OpenCV.
image_list : 此参数是通过OpenCV加载的图像的列表。
image_shape: A tuple containing the width and height of each image in the montage.
image_shape : 一个元组,包含蒙太奇中每个图像的宽度和高度。
montage_shape: A second tuple, this one specifying the number of columns and rows in the montage. Here we indicate that our montage will have 5columns (5 images wide) and 5rows (5 images tall).
montage_shape : 第二个元组,该元组指定蒙太奇中的列和行数。 在这里,我们指示蒙太奇将有5列(宽5幅图像)和5行(高5幅图像)。
The build_montages method returns a list of montage images in NumPy array format.
build_montages方法以NumPy数组格式返回蒙太奇图像的列表。
Note: Empty space in the montage will be filled with black pixels.
注意: 蒙太奇中的空白将被黑色像素填充。
The class label is colored green for “healthy” and red for “parkinsons”
班级标签的绿色表示 “健康” ,红色表示 “帕金森”
Output :
输出:
Validation Accuracy for wave images is 65%
波浪图像的验证精度为65%
Transforms are passed on when creating the “ImageDataBunch” objects.Genearlly, you may enable the “Default” transforms by calling
创建“ ImageDataBunch”对象时会传递转换。通常,您可以通过调用启用“默认”转换
tfms = get_transforms()
tfms = get_transforms()
The tuple contating transforms has 2 lists nested.
元组连续转换有2个嵌套列表。
One is for the training dataset. 一种是用于训练数据集。 Second one is for the validation dataset that involves minimal transforms/just resizing. 第二个是用于验证数据集,该数据集涉及最少的转换/仅调整大小。[RandTransform(tfm=TfmCrop (crop_pad), kwargs={‘row_pct’: (0, 1), ‘col_pct’: (0, 1), ‘padding_mode’: ‘reflection’}, p=1.0, resolved={}, do_run=True, is_random=True, use_on_y=True), RandTransform(tfm=TfmAffine (dihedral_affine), kwargs={}, p=1.0, resolved={}, do_run=True, is_random=True, use_on_y=True), RandTransform(tfm=TfmCoord (symmetric_warp), kwargs={‘magnitude’: (-0.2, 0.2)}, p=0.75, resolved={}, do_run=True, is_random=True, use_on_y=True), RandTransform(tfm=TfmAffine (rotate), kwargs={‘degrees’: (-180, 180)}, p=0.75, resolved={}, do_run=True, is_random=True, use_on_y=True), RandTransform(tfm=TfmAffine (zoom), kwargs={‘scale’: (1.0, 1.1), ‘row_pct’: (0, 1), ‘col_pct’: (0, 1)}, p=0.75, resolved={}, do_run=True, is_random=True, use_on_y=True), RandTransform(tfm=TfmLighting (brightness), kwargs={‘change’: (0.4, 0.6)}, p=0.75, resolved={}, do_run=True, is_random=True, use_on_y=True), RandTransform(tfm=TfmLighting (contrast), kwargs={‘scale’: (0.8, 1.25)}, p=0.75, resolved={}, do_run=True, is_random=True, use_on_y=True)]
[RandTransform(tfm = TfmCrop (crop_pad),kwargs = {'row_pct':(0,1),'col_pct':(0,1),'padding_mode':'reflection'},p = 1.0,已解决= {} ,do_run = True,is_random = True,use_on_y = True),RandTransform(tfm = TfmAffine ( dihedral_affine) ,kwargs = {},p = 1.0,resolve = {},do_run = True,is_random = True,use_on_y = True), RandTransform(tfm = TfmCoord (symmetric_warp),kwargs = {'magnitude':(- 0.2,0.2 )},p = 0.75,resolve = {},do_run = True,is_random = True,use_on_y = True),RandTransform(tfm = TfmAffine (旋转 ),kwargs = {'度数:(-180,180)},p = 0.75,已解析= {},do_run = True,is_random = True,use_on_y = True),RandTransform(tfm = TfmAffine(缩放 ), kwargs = {'scale':(1.0,1.1),'row_pct':(0,1),'col_pct':(0,1)},p = 0.75,resolve = {},do_run = True,is_random = True ,use_on_y = True),RandTransform(tfm = TfmLighting(亮度) ,kwargs = {'change':( 0.4,0.6 )},p = 0.75,resolve = {},do_run = True,is_random = True,use_on_y = True) ,RandTransform(tfm = TfmLighting(contrast) ,kwargs = {'scale':( 0.8,1.25 )},p = 0.75,resolve = {},do_run = True,is_random = True,use_on_y = True)]]
[RandTransform(tfm=TfmCrop (crop_pad), kwargs={}, p=1.0, resolved={}, do_run=True, is_random=True, use_on_y=True)]
[RandTransform(tfm = TfmCrop(crop_pad) ,kwargs = {},p = 1.0,已解决= {},do_run = True,is_random = True,use_on_y = True)]
data.classes :Class Labels for the training samples : [‘healthy’, ‘parkinson’]
data.classes : 训练样本的类别标签:['healthy','parkinson']
Here we could see that we could easily get a validation accuracy 0f 86% for Spiral images with only few lines of code as compared to the opencv+ ML code.
在这里我们可以看到,与opencv + ML代码相比,只需几行代码,就可以轻松获得螺旋图像的验证精度0f 86%。
This validation accuracy is 83% for wave images with only few lines of code as compared to the opencv+ ML code.
与opencv + ML代码相比,仅几行代码的波形图像的验证精度为83%。
connect
连接
Reference:
参考:
翻译自: https://medium.com/@nayakpplaban/detecting-parkinsons-with-opencv-computer-vision-and-the-spiral-wave-test-e8de3b30f5e6
计算机视觉 opencv
相关资源:四史答题软件安装包exe