从头开始 - 构建模型并运行应用程序以执行图像的推断
建议使用虚拟环境进行设置,以免与其他现有版本的Python(3.8至3.11之间)相抵触。 Python版本由于Scikit-Learn库的要求而受到限制。 Scikit-Learn版本(1.4.0)安装由需求txt处理。如果您决定不使用虚拟环境,请确保卸载其他非兼容版本的Python。还要检查需求文件中列出的依赖项的现有非兼容版本。这可能有点麻烦,因此最好使用虚拟环境,然后让Python找出所有可接受的版本控制。
1-下载/安装可用的64位Python版本(3.8和3.11之间的任何内容)
2-从Windows命令提示
3-在项目目录中创建一个VirtualEnv -example:Python -M Virtualenv - Python Python310 ASL [如果使用Python 3.10] - 以查看系统上安装了哪些版本的Python:Py -0-!! set -executionpolicy -scope currentuser -ectecutionPolicy -Force -force
4-从项目目录内部激活新Virtualenv -example:。 asl scripts activate
5-应该看到更新的命令提示
6-检查Virtualenv使用的Python的版本 - example:Python -version-输出:Python 3.10.0 [或任何您的版本]
7- CD进入Virtualenv目录 - 示例:CD ASL
8-克隆github回购到本地机器 - example:git克隆https://github.com/cpetrella-sketch/asl-recognition.git- utput-输出:克隆到'asl-recognition'...远程:枚举对象:枚举对象:518,完成。远程:计数对象:100%(88/88),完成。远程:压缩对象:100%(54/54),完成。遥控器:总计518(三角洲35),重复使用的72(Delta 27),包装重新使用的430接收对象:100%(518/518),40.60 MIB | 3.62 MIB/S,完成。解决三角洲:100%(270/270),完成。
9-安装所需的Python依赖项 - 更改目录:cd。 asl -cognition aslml
- 安装依赖项 - example:pip install -r unigess.txt-输出:...安装收集的软件包:
10-从以下链接下载培训和测试数据集 - Full_training_dataset.zip(2.51 GB) 〜。/asl-cognition/aslml/data/ - 到达DIR的路径应为:〜。/asl-cognition/aslml/images/full_training_dataset/ - 目录应为Alphabet中的每个字母(不包括J,z,z)具有一个子目录
–full_testing_dataset.zip(38.8 mb)https://drive.google.com/file/file/d/1urn66jntxcs-s_1kvrsh11pe3vbp3vd-/view?usp = sharing? 〜。/asl-cognition/aslml/images/full_testing_dataset/ - 目录应为字母中的每个字母提供一个子目录(不包括J,z)
11-从full_training_dataset图像创建里程碑式数据集 - 示例:从内部./asl -recognition/aslml/ - create_dataset.py内部,将“ sampleSizeperCentage”更改为所需的采样率。默认值设置为所有图像的100%。 - python。 create_dataset.py - 输出:目前在目录a上工作...目前在目录B上工作………目前在目录V…目前在目录上工作y ...
Dataset sample size selected: 10% Total number of images processed (10% of Full Dataset): 8033 Successful detections (79.73359890451886%): 6405 Failed detections: 1628 Landmark Detection Complete...Exporting x/y coords and labels to 'data.pickle' Execution Time: 2184 Seconds
12-找到最佳的随机森林分类器参数并在数据集上训练模型 - 示例:来自〜。/asl -recognition/aslml - python。 train_classifier.py.py - 输出:将数据分配为测试和培训,并保留20.0%用于测试。
开始网格搜索...为16个候选人中的每一个拟合5倍,总计80个拟合[cv] end bootstrap = true,max_depth = none,min_samples_leaf = 1,min_samples_split = 2,n_estimators = 100;总时间= 5.1s [cv] end bootstrap = true,max_depth = none,min_samples_leaf = 1,min_samples_split = 2,n_estimators = 100;总时间= 5.4s…[CV] end bootstrap = false,max_depth = 10,min_samples_leaf = 2,min_samples_split = 2,n_estimators = 200;总时间= 9.6s [cv] end bootstrap = false,max_depth = 10,min_samples_leaf = 2,min_samples_split = 2,n_estimators = 200;总时间= 9.2s这是发现的最佳参数:
{'bootstrap':false,'max_depth':none,'min_samples_leaf':1,'min_samples_split':2,'n_estimators':200}分类报告:
precision recall f1-score support
S 0.74 0.95 0.83 58
T 0.94 0.96 0.95 53
U 0.67 0.73 0.70 56
V 0.81 0.75 0.78 59
W 1.00 0.96 0.98 56
X 0.98 0.94 0.96 52
Y 0.97 0.97 0.97 58
accuracy 0.91 1281
宏公平0.92 0.91 0.91 1281加权avg 0.92 0.91 0.92 1281
91.49102263856362%正确分类
执行时间:103.0892658236426秒
13-测试在新测试数据上新创建的模型的准确性 - 示例:来自〜/asl -cognition/aslml - python。
图像文件:a0001_test.jpg在用户图像中成功检测到了地标:a0001_test.jpg
该模型预测A dirname是:正确!!
图像文件:a0024_test.jpg在用户图像中成功检测到了地标:a0024_test.jpg
该模型预测A dirname是:正确!! …
图像文件:hand3_y_dif_seg_5_cropped.jpeg在用户图像中成功检测到了地标:hand3_y_dif_seg_5_cropped.jpeg
该模型预测y dirname是:y正确!
使用RandomForestClassifer训练的模型:百分比成功的里程碑检测:69%百分比成功的字母预测检测:76%
可用的测试图像总数:2510 26%随机抽样。处理的图像总数:622正确的预测总数:332不正确的预测总数:103成功的地标检测总数:435未成功的地标检测总数:187
使用应用程序
14-将新创建的模型复制到CGI -bin - 示例:复制'aslmodel.job'from'' 。 asl-cognition aslml models'to'' 。
使用应用程序
1 - Open a web browser and access the web page -- example : http://localhost:8990 2 - Upload a .jpg ASL gesture image for inference -- click the "Upload File" button -- select an image from your local storage -- wait for status pop up -- example : localhost:8990 says Upload successful -- click "ok" -- screen updates with image uploaded and inference result -- example :