• 大小: 3MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-09-12
  • 语言: 其他
  • 标签: OPencv  图像分类  

资源简介

使用Opencv进行图像分类的应用程序,对图像的区分程度不错。

资源截图

代码片段和文件信息

import cv2
import pandas as pd
import numpy as np
from numpy.linalg import norm
import glob
import pickle
# local modules
#RandomForestClassifier
def RandomForest_learn(xyX_testY_test):
    from sklearn.ensemble import RandomForestClassifier
    classifier = RandomForestClassifier(n_estimators=3 criterion=‘entropy‘ random_state=0)
    classifier.fit(x y)
    y_pred = classifier.predict(X_test)
    pickle.dump(classifier open(‘RandomForestClassifier.sav‘ ‘wb‘))
    n = 0
    p = 0
    i = 0
    while i < len(y_pred):
        if y_pred[i] == Y_test[i]:
            p = p + 1
        else:
            n = n + 1
        i = i + 1
    print(n)
    print(p)
    accuracy = (p / len(y_pred)) * 100
    print(accuracy ‘% RandomForestClassifier‘)


#DecisionTreeClassifier
def DecisionTree_learn(xyX_testY_test):
    from sklearn.tree import DecisionTreeClassifier
    classifier = DecisionTreeClassifier(criterion=‘entropy‘ random_state=0)
    classifier.fit(x y)
    y_pred = classifier.predict(X_test)
    pickle.dump(classifier open(‘DecisionTreeClassifier.sav‘ ‘wb‘))
    n = 0
    p = 0
    i = 0
    while i < len(y_pred):
        if y_pred[i] == Y_test[i]:
            p = p + 1
        else:
            n = n + 1
        i = i + 1
    print(n)
    print(p)
    accuracy = (p / len(y_pred)) * 100
    print(accuracy ‘% DecisionTreeClassifier‘)




#Kernel SVM classification
def KernelSVM_learn(xyX_testY_test):
    # Fitting SVM to the Training set
    from sklearn.svm import SVC
    classifier = SVC(kernel=‘rbf‘ gamma=5.383 C=2.67)
    classifier.fit(x y)
    y_pred = classifier.predict(X_test)
    pickle.dump(classifier open(‘KernelSVMClassifier.sav‘ ‘wb‘))
    n = 0
    p = 0
    i = 0
    while i < len(y_pred):
        if y_pred[i] == Y_test[i]:
            p = p + 1
        else:
            n = n + 1
        i = i + 1
    print(n)
    print(p)
    accuracy = (p / len(y_pred)) * 100
    print(accuracy ‘% KernelSVM‘)



#Linear SVM classification
def LinearSVM_learn(xyX_testY_test):
    # Fitting SVM to the Training set
    from sklearn.svm import SVC
    classifier = SVC(kernel=‘linear‘ random_state=0)
    classifier.fit(x y)
    y_pred = classifier.predict(X_test)
    pickle.dump(classifier open(‘LinearSVMClassifier.sav‘ ‘wb‘))
    n = 0
    p = 0
    i = 0
    while i < len(y_pred):
        if y_pred[i] == Y_test[i]:
            p = p + 1
        else:
            n = n + 1
        i = i + 1
    print(n)
    print(p)
    accuracy = (p / len(y_pred)) * 100
    print(accuracy ‘% linearSVM‘)


#logit classification
def Logit_learn(xyX_testY_test):
    # Fitting Logit to the Training set
    from sklearn.linear_model import LogisticRegression
    classifier = LogisticRegression(random_state = 0)
    classifier.fit(x y)
    y_pred = classifier.predict(X_test)
    pickle.dump(classifier open(‘LogisticClassifier.sav‘ 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-10-19 10:42  Take_photo_By_Finger-master\
     文件        1203  2018-10-19 10:42  Take_photo_By_Finger-master\.gitignore
     文件        3768  2018-10-19 10:42  Take_photo_By_Finger-master\DecisionTreeClassifier.sav
     文件      658183  2018-10-19 10:42  Take_photo_By_Finger-master\KNeighborsClassifier.sav
     文件       59353  2018-10-19 10:42  Take_photo_By_Finger-master\KernelSVMClassifier.sav
     文件       35149  2018-10-19 10:42  Take_photo_By_Finger-master\LICENSE
     文件       81703  2018-10-19 10:42  Take_photo_By_Finger-master\LinearSVMClassifier.sav
     文件        1332  2018-10-19 10:42  Take_photo_By_Finger-master\LogisticClassifier.sav
     文件         206  2018-10-19 10:42  Take_photo_By_Finger-master\README.md
     文件       12326  2018-10-19 10:42  Take_photo_By_Finger-master\RandomForestClassifier.sav
     目录           0  2018-10-19 10:42  Take_photo_By_Finger-master\gr\
     文件         169  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937946.541338.png
     文件         157  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937946.5563493.png
     文件         186  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937946.5593388.png
     文件      131729  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937946.5633383.png
     文件         979  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937946.587339.png
     文件        1174  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937946.590338.png
     文件         643  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937946.605342.png
     文件       10461  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937946.608341.png
     文件       11567  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937946.6213424.png
     文件          79  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937946.6253388.png
     文件        2229  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937946.6283371.png
     文件         314  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937948.9613378.png
     文件         500  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937948.9953377.png
     文件         978  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937949.278338.png
     文件         962  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937949.4093368.png
     文件        1020  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937949.4453394.png
     文件        1335  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937949.47834.png
     文件        1461  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937949.5053358.png
     文件          67  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937949.5693386.png
     文件         336  2018-10-19 10:42  Take_photo_By_Finger-master\gr\1539937949.57334.png
............此处省略264个文件信息

评论

共有 条评论