TWI824796B - Method for classifying images, computer device and storage medium - Google Patents
Method for classifying images, computer device and storage medium Download PDFInfo
- Publication number
- TWI824796B TWI824796B TW111140738A TW111140738A TWI824796B TW I824796 B TWI824796 B TW I824796B TW 111140738 A TW111140738 A TW 111140738A TW 111140738 A TW111140738 A TW 111140738A TW I824796 B TWI824796 B TW I824796B
- Authority
- TW
- Taiwan
- Prior art keywords
- target
- image
- classification
- matrix
- training
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 44
- 239000011159 matrix material Substances 0.000 claims abstract description 179
- 238000012549 training Methods 0.000 claims abstract description 88
- 238000013145 classification model Methods 0.000 claims abstract description 87
- 238000012360 testing method Methods 0.000 claims abstract description 51
- 238000012545 processing Methods 0.000 claims abstract description 16
- 230000006870 function Effects 0.000 claims description 16
- 238000004364 calculation method Methods 0.000 claims description 9
- 239000000284 extract Substances 0.000 claims description 3
- 238000004590 computer program Methods 0.000 description 15
- 230000008569 process Effects 0.000 description 9
- 238000010586 diagram Methods 0.000 description 6
- 241000282472 Canis lupus familiaris Species 0.000 description 3
- 241000282326 Felis catus Species 0.000 description 3
- 241001465754 Metazoa Species 0.000 description 3
- 230000009467 reduction Effects 0.000 description 3
- 241000196324 Embryophyta Species 0.000 description 2
- 238000004422 calculation algorithm Methods 0.000 description 2
- 238000013527 convolutional neural network Methods 0.000 description 2
- 241000190070 Sarracenia purpurea Species 0.000 description 1
- 238000009825 accumulation Methods 0.000 description 1
- 230000004931 aggregating effect Effects 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000000354 decomposition reaction Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000000605 extraction Methods 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 238000003064 k means clustering Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000010606 normalization Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Abstract
Description
本發明涉及影像處理領域,尤其涉及一種圖像分類方法、電腦設備及儲存介質。 The present invention relates to the field of image processing, and in particular, to an image classification method, computer equipment and storage medium.
在目前的圖像分類網路中,全連接層中龐大的運算量會導致運算用時較長,造成圖像分類速度緩慢,因此,如何在確保分類準確率的情況下提高圖像分類的速度,成為了目前需要解決的問題。 In the current image classification network, the huge amount of calculations in the fully connected layer will cause the calculation to take a long time, causing the image classification speed to be slow. Therefore, how to improve the speed of image classification while ensuring the classification accuracy? , has become a problem that needs to be solved currently.
鑒於以上內容,有必要提供一種圖像分類方法、電腦設備及儲存介質,能夠解決難以減少全連接層中龐大的運算量而導致圖像分類速度緩慢的問題。 In view of the above, it is necessary to provide an image classification method, computer equipment and storage medium that can solve the problem of slow image classification caused by the difficulty in reducing the huge amount of calculations in the fully connected layer.
本申請提供一種圖像分類方法,所述圖像分類方法包括:獲取分類網路,並獲取待分類圖像、訓練圖像及多張測試圖像,基於所述訓練圖像對所述分類網路進行訓練,得到第一分類模型,計算所述第一分類模型對所述多張測試圖像的預測正確率,若所述預測正確率小於預設值,從所述多張測試圖像中選取目標圖像對所述第一分類模型進行調整,得到第二分類模型,其中,所述第二分類模型包括壓平層、全連接層及分類層,將所述待分類圖像輸入到所述第二分類模型中,並獲取從所述壓平層輸出的初始特徵矩陣,若所述初始 特徵矩陣的維度小於所述全連接層中的初始權重矩陣的維度,對所述初始特徵矩陣進行升維處理,得到目標特徵矩陣,將所述初始權重矩陣中的元素進行重新排列,得到目標權重矩陣,根據所述目標權重矩陣及所述目標特徵矩陣生成目標向量,將所述目標向量輸入到所述分類層中,得到所述待分類圖像的分類結果。 This application provides an image classification method. The image classification method includes: obtaining a classification network, and obtaining images to be classified, training images and multiple test images, and classifying the classification network based on the training images. The first classification model is obtained through training, and the prediction accuracy rate of the first classification model for the plurality of test images is calculated. If the prediction accuracy rate is less than the preset value, the prediction accuracy rate of the first classification model is calculated from the plurality of test images. Select the target image to adjust the first classification model to obtain a second classification model, wherein the second classification model includes a flattening layer, a fully connected layer and a classification layer, and input the image to be classified into the In the second classification model, and obtain the initial feature matrix output from the flattening layer, if the initial The dimension of the feature matrix is smaller than the dimension of the initial weight matrix in the fully connected layer. The initial feature matrix is dimensionally increased to obtain the target feature matrix. The elements in the initial weight matrix are rearranged to obtain the target weight. matrix, generate a target vector according to the target weight matrix and the target feature matrix, input the target vector into the classification layer, and obtain the classification result of the image to be classified.
根據本申請可選實施例,所述基於所述訓練圖像對所述分類網路進行訓練,得到第一分類模型包括:基於所述訓練圖像計算所述分類網路的損失值,基於所述損失值對所述分類網路進行調整,直至所述損失值下降到最低後停止調整,得到所述第一分類模型。 According to an optional embodiment of the present application, said training the classification network based on the training image to obtain the first classification model includes: calculating the loss value of the classification network based on the training image, based on the The classification network is adjusted according to the loss value until the loss value drops to the minimum and then the adjustment is stopped to obtain the first classification model.
根據本申請可選實施例,所述基於所述訓練圖像計算所述分類網路的損失值包括:所述損失值的計算方法為:
根據本申請可選實施例,所述計算所述第一分類模型對所述多張測試圖像的預測正確率包括:獲取所述多張測試圖像的類別標籤,將所述多張 測試圖像輸入到所述第一分類模型中,得到每張測試圖像的預測結果,將所述預測結果與對應的類別標籤進行比較,並將與所述對應的類別標籤相同的預測結果確定為目標結果,將所述目標結果對應的測試圖像確定為所述目標圖像,統計多張所述目標圖像的第一數量及所述多張測試圖像的第二數量,計算所述第一數量在所述第二數量中所佔的比率,得到所述預測正確率。 According to an optional embodiment of the present application, calculating the prediction accuracy of the first classification model for the plurality of test images includes: obtaining the category labels of the plurality of test images, and converting the plurality of test images into The test image is input into the first classification model, the prediction result of each test image is obtained, the prediction result is compared with the corresponding category label, and the prediction result that is the same as the corresponding category label is determined To determine the target result, determine the test image corresponding to the target result as the target image, count the first number of the target images and the second number of the test images, and calculate the The ratio of the first quantity to the second quantity is the prediction accuracy rate.
根據本申請可選實施例,所述從所述多張測試圖像中選取目標圖像對所述第一分類模型進行調整,得到第二分類模型包括:對多張所述目標圖像進行聚類處理,生成多個聚類中心,將每個聚類中心對應的目標圖像輸入到所述第一分類模型中進行訓練,直至所述預測正確率大於或者等於所述預設值,得到所述第二分類模型。 According to an optional embodiment of the present application, selecting a target image from the plurality of test images to adjust the first classification model to obtain the second classification model includes: aggregating the plurality of target images. Class processing, generate multiple clustering centers, input the target image corresponding to each clustering center into the first classification model for training until the prediction accuracy rate is greater than or equal to the preset value, and obtain the Describe the second classification model.
根據本申請可選實施例,所述若所述初始特徵矩陣的維度小於所述全連接層中的初始權重矩陣的維度,則對所述初始特徵矩陣進行升維處理,得到目標特徵矩陣包括:統計所述初始特徵矩陣的矩陣行數及矩陣列數,將所述矩陣行數與所述矩陣列數進行相乘運算,得到目標乘積,將所述目標乘積進行質因數分解,得到多個質因數,將所述多個質因數中相同的任意兩個質因數組合成質因數對,並計算所述質因數對中兩個質因數的乘積,得到特徵乘積,每個質因數只能組合一次,根據所述目標乘積及所述特徵乘積從所述質因數對中選取目標質因數對,提取所述目標質因數對中的一個質因數,得到特徵質因數,根據所述目標質因數對的對數及所述特徵質因數生成特徵數值,在所述多個質因數中將所述目標質因數對替換為零,在完成替換後將所有不為零的質因數進行相乘運算,得到目標數值,基於配置值、所述目標數值及所述特徵數值,對所述初始特徵矩陣進行升維處理,得到所述目標特徵矩陣。 According to an optional embodiment of the present application, if the dimension of the initial feature matrix is smaller than the dimension of the initial weight matrix in the fully connected layer, then performing dimensionality enhancement processing on the initial feature matrix to obtain the target feature matrix includes: Count the number of matrix rows and matrix columns of the initial feature matrix, multiply the number of matrix rows and the number of matrix columns to obtain a target product, and decompose the target product into prime factors to obtain multiple prime factors. Factor, combine any two identical prime factors among the multiple prime factors into a prime factor pair, and calculate the product of the two prime factors in the prime factor pair to obtain the characteristic product. Each prime factor can only be combined once , select a target prime factor pair from the prime factor pair according to the target product and the characteristic product, extract a prime factor in the target prime factor pair, and obtain a characteristic prime factor. According to the target prime factor pair The logarithm and the characteristic prime factors generate a characteristic value, the target prime factor pair is replaced with zero among the plurality of prime factors, and after the replacement is completed, all prime factors that are not zero are multiplied to obtain the target value. , based on the configuration value, the target value and the feature value, perform dimensionality enhancement processing on the initial feature matrix to obtain the target feature matrix.
根據本申請可選實施例,所述將所述初始權重矩陣的元素進行重新排列,得到目標權重矩陣包括:將所述初始權重矩陣中每列的最後一個元素確定為目標元素,重複將每列的列首位置的元素調整到每列的列尾位置,每列其它元素的位置依序向列首位置移動,直到所述目標元素移動到列首位置後停 止排列,得到所述目標權重矩陣。 According to an optional embodiment of the present application, rearranging the elements of the initial weight matrix to obtain the target weight matrix includes: determining the last element of each column in the initial weight matrix as the target element, and repeatedly The element at the head of the column is adjusted to the end of each column, and the positions of other elements in each column are moved to the head of the column in sequence until the target element moves to the head of the column and then stops. After permutation, the target weight matrix is obtained.
根據本申請可選實施例,所述根據所述目標權重矩陣及所述目標特徵矩陣生成目標向量包括:將所述目標權重矩陣與所述目標特徵矩陣進行相乘運算,得到所述目標向量。 According to an optional embodiment of the present application, generating a target vector based on the target weight matrix and the target feature matrix includes: performing a multiplication operation on the target weight matrix and the target feature matrix to obtain the target vector.
本申請提供一種電腦設備,所述電腦設備包括:儲存器,儲存至少一個指令;及處理器,執行所述至少一個指令以實現所述的圖像分類方法。 The present application provides a computer device, which includes: a storage that stores at least one instruction; and a processor that executes the at least one instruction to implement the image classification method.
本申請提供一種電腦可讀儲存介質,所述電腦可讀儲存介質中儲存有至少一個指令,所述至少一個指令被電腦設備中的處理器執行以實現所述的圖像分類方法。 The present application provides a computer-readable storage medium. The computer-readable storage medium stores at least one instruction. The at least one instruction is executed by a processor in a computer device to implement the image classification method.
由以上技術方案可以看出,本申請透過計算所述第一分類模型對所述多張測試圖像的預測正確率,進而將所述預測準確率與所述預設值進行比較以確定是否要對所述第一分類模型進行調整,能夠提高所述第二分類模型的預測能力,由於在調整過程中只選取了目標圖像對所述第一分類模型進行調整,能夠降低調整過程中的運算量,從而提高所述第二分類模型的生成效率,將所述待分類圖像輸入所述第二分類模型中,並獲取從壓平層輸出的初始特徵矩陣,若所述初始特徵矩陣的維度小於所述全連接層中的初始權重矩陣的維度,則對所述初始特徵矩陣進行升維處理,得到目標特徵矩陣,透過改變所述目標特徵矩陣的維度,能夠增加每次運算的參數量,獲取全連接層的初始權重矩陣,並將所述初始權重矩陣的元素進行重新排列,得到所述目標權重矩陣,將所述目標權重矩陣與所述目標特徵矩陣進行乘累加運算,得到目標向量,並將所述目標向量輸入到所述分類層中,得到所述待分類圖像的分類結果,由於將所述初始權重矩陣中的元素進行重新排列後改變了元素的運算順序,因此能夠確保每次運算時都會有權重矩陣中的元素參與運算,進而能夠避免輸出空白結果(即避免進行無效運算),從而能夠減少運算的次數及運算所用的時間,因此能夠加快圖像分類的速度。 It can be seen from the above technical solutions that this application calculates the prediction accuracy rate of the first classification model for the plurality of test images, and then compares the prediction accuracy rate with the preset value to determine whether to Adjusting the first classification model can improve the prediction ability of the second classification model. Since only the target image is selected to adjust the first classification model during the adjustment process, the calculation time during the adjustment process can be reduced. quantity, thereby improving the generation efficiency of the second classification model, input the image to be classified into the second classification model, and obtain the initial feature matrix output from the flattening layer, if the dimensions of the initial feature matrix is smaller than the dimension of the initial weight matrix in the fully connected layer, then the initial feature matrix is dimensioned to obtain a target feature matrix. By changing the dimension of the target feature matrix, the amount of parameters in each operation can be increased, Obtain the initial weight matrix of the fully connected layer, rearrange the elements of the initial weight matrix to obtain the target weight matrix, perform a multiplication and accumulation operation on the target weight matrix and the target feature matrix to obtain the target vector, And input the target vector into the classification layer to obtain the classification result of the image to be classified. Since the elements in the initial weight matrix are rearranged and the order of operations of the elements is changed, it can ensure that each During each operation, elements in the weight matrix will participate in the operation, thereby avoiding the output of blank results (that is, avoiding invalid operations), thereby reducing the number of operations and the time spent in operations, thus speeding up image classification.
1:電腦設備 1:Computer equipment
2:拍攝設備 2: Shooting equipment
12:儲存器 12:Storage
13:處理器 13: Processor
101~109:步驟 101~109: Steps
圖1是本申請圖像分類方法的較佳實施例的應用環境圖。 Figure 1 is an application environment diagram of a preferred embodiment of the image classification method of the present application.
圖2是本申請圖像分類方法的較佳實施例的流程圖。 Figure 2 is a flow chart of a preferred embodiment of the image classification method of the present application.
圖3是本申請實現圖像分類方法的較佳實施例的電腦設備的結構示意圖。 Figure 3 is a schematic structural diagram of a computer device for implementing an image classification method according to a preferred embodiment of the present application.
為了使本申請的目的、技術方案和優點更加清楚,下面結合附圖和具體實施例對本申請進行詳細描述。 In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be described in detail below with reference to the accompanying drawings and specific embodiments.
如圖1所示,是本申請一種圖像分類方法的較佳實施例的應用環境圖。所述圖像分類方法可應用於一個或者多個電腦設備1中,所述電腦設備1與拍攝設備2相通信,所述拍攝設備2可以是攝像頭,也可以是實現拍攝的其它設備,例如,透過拍攝設備2能夠拍攝目標物件,得到待分類圖像,其中,所述目標物件可以是貓、狗等動物,也可以是水杯、玩具等產品。
As shown in Figure 1, it is an application environment diagram of a preferred embodiment of an image classification method in this application. The image classification method can be applied to one or
所述電腦設備1是一種能夠按照事先設定或儲存的指令,自動進行參數值計算和/或資訊處理的設備,其硬體包括,但不限於:微處理器、專用積體電路(Application Specific Integrated Circuit,ASIC)、可程式設計閘陣列(Field-Programmable Gate Array,FPGA)、數位訊號處理器(Digital Signal Processor,DSP)、嵌入式設備等。
The
所述電腦設備1可以是任何一種可與用戶進行人機交互的電腦產品,例如,個人電腦、平板電腦、智慧手機、個人數位助理(Personal Digital Assistant,PDA)、遊戲機、互動式網路電視(Internet Protocol Television,IPTV)、穿戴式智能設備等。所述電腦設備1還可以包括網路設備和/或使用者設備。其中,所述網路設備包括,但不限於單個網路伺服器、多個網路伺服器組成的伺服器組或基於雲計算(Cloud Computing)的由大量主機或網路伺服器構成的雲。
The
所述電腦設備1所處的網路包括但不限於網際網路、廣域網路、都會區網路、區域網路、虛擬私人網路(Virtual Private Network,VPN)等。
The network where the
如圖2所示,是本申請一種圖像分類方法的較佳實施例的流程圖。根據不同的需求,該流程圖中各個步驟的順序可以根據實際檢測要求進行調整,某些步驟可以省略。所述方法的執行主體為電腦設備,例如圖1所示的電腦設備1。
As shown in Figure 2, it is a flow chart of a preferred embodiment of an image classification method of the present application. According to different needs, the order of each step in this flow chart can be adjusted according to the actual detection requirements, and some steps can be omitted. The execution subject of the method is a computer device, such as the
步驟101,獲取分類網路,並獲取待分類圖像、訓練圖像及多張測試圖像。 Step 101: Obtain the classification network, and obtain the images to be classified, training images and multiple test images.
在本申請的至少一個實施例中,所述分類網路是指能夠預測出所述待分類圖像的類別的網路。在本申請的至少一個實施例中,所述待分類圖像是指需要進行分類的圖像。在本申請的至少一個實施例中,所述訓練圖像可用於對所述分類網路進行訓練。在本申請的至少一個實施例中,所述多張測試圖像是指圖像的類別已知的圖像,所述多張測試圖像可用於計算所述分類網路的準確率。在本申請的至少一個實施例中,所述電腦設備基於卷積神經網路構建所述分類網路。其中,所述卷積神經網路可以為VGG16網路、ResNet網路等。 In at least one embodiment of the present application, the classification network refers to a network that can predict the category of the image to be classified. In at least one embodiment of the present application, the image to be classified refers to an image that needs to be classified. In at least one embodiment of the present application, the training images may be used to train the classification network. In at least one embodiment of the present application, the multiple test images refer to images whose categories are known, and the multiple test images can be used to calculate the accuracy of the classification network. In at least one embodiment of the present application, the computer device constructs the classification network based on a convolutional neural network. Among them, the convolutional neural network can be a VGG16 network, a ResNet network, etc.
在本申請的至少一個實施例中,所述電腦設備獲取待分類圖像包括:所述電腦設備控制所述拍攝設備拍攝待分類物件,得到所述待分類圖像。其中,所述待分類物件可以是貓、狗等動物,也可以是花卉類等植物。 In at least one embodiment of the present application, the computer device acquiring the image to be classified includes: the computer device controlling the photographing device to capture the object to be classified to obtain the image to be classified. The objects to be classified may be animals such as cats and dogs, or plants such as flowers.
在本申請的至少一個實施例中,所述電腦設備從預設的第一資料庫中獲取所述訓練圖像。在本申請的至少一個實施例中,所述電腦設備從預設的第二資料庫中獲取所述多張測試圖像及每張測試圖像的類別標籤。其中,所述類別標籤是指所述測試圖像的真實類別。所述第二資料庫可以為CIFAR-10、ImageNet等資料庫。 In at least one embodiment of the present application, the computer device obtains the training image from a preset first database. In at least one embodiment of the present application, the computer device obtains the plurality of test images and the category label of each test image from a preset second database. Wherein, the category label refers to the real category of the test image. The second database may be CIFAR-10, ImageNet or other databases.
在本申請的至少一個實施例中,為了確保所述訓練圖像及所述多張測試圖像的亮度及尺寸更加統一,可以將獲取到的訓練圖像及多張測試圖像進行均衡化及歸一化處理。所述訓練圖像及所述多張測試圖像是指可以包括了 動物(例如,小狗,小貓等)、植物(例如,花、樹等)等多個種類的物品圖像。 In at least one embodiment of the present application, in order to ensure that the brightness and size of the training image and the multiple test images are more uniform, the acquired training image and the multiple test images can be equalized and Normalization processing. The training image and the multiple test images may include Images of multiple types of items such as animals (for example, puppies, kittens, etc.), plants (for example, flowers, trees, etc.).
步驟102,基於所述訓練圖像對所述分類網路進行訓練,得到第一分類模型。 Step 102: Train the classification network based on the training images to obtain a first classification model.
在本申請的至少一個實施例中,所述第一分類模型是指使用所述訓練圖像對所述分類網路進行訓練後所得到的模型。 In at least one embodiment of the present application, the first classification model refers to a model obtained by training the classification network using the training images.
在本申請的至少一個實施例中,所述電腦設備基於所述訓練圖像對所述分類網路進行訓練,得到第一分類模型包括:所述電腦設備基於所述訓練圖像計算所述分類網路的損失值,進一步地,所述電腦設備基於所述損失值對所述分類網路進行調整,直至所述損失值下降到最低後停止調整,得到所述第一分類模型。 In at least one embodiment of the present application, the computer device trains the classification network based on the training image, and obtaining the first classification model includes: the computer device calculates the classification based on the training image. The loss value of the network. Further, the computer device adjusts the classification network based on the loss value until the loss value drops to a minimum and then stops adjusting, thereby obtaining the first classification model.
透過上述實施方式,基於所述損失值對所述分類進行訓練,直至所述分類網路收斂,得到所述第一分類模型,能夠提高所述第一分類模型的分類準確性。 Through the above implementation, the classification is trained based on the loss value until the classification network converges, and the first classification model is obtained, which can improve the classification accuracy of the first classification model.
具體地,所述電腦設備基於所述訓練圖像計算所述分類網路的損失值包括:所述電腦設備將所述訓練圖像輸入到所述分類網路中,得到所述訓練圖像的標註類別,所述電腦設備基於所述訓練圖像及所述標註類別計算所述損失值。 Specifically, the computer device calculating the loss value of the classification network based on the training image includes: the computer device inputs the training image into the classification network, and obtains the loss value of the training image. Label category, the computer device calculates the loss value based on the training image and the label category.
所述損失值的計算方法為:
步驟103,計算所述第一分類模型對所述多張測試圖像的預測正確率。 Step 103: Calculate the prediction accuracy rate of the first classification model for the plurality of test images.
在本申請的至少一個實施例中,所述預測正確率是指所述第一分類模型對所述多張測試圖像進行正確分類的概率。 In at least one embodiment of the present application, the prediction accuracy rate refers to the probability that the first classification model correctly classifies the multiple test images.
在本申請的至少一個實施例中,所述電腦設備計算所述第一分類模型對所述多張測試圖像的預測正確率包括:所述電腦設備獲取所述多張測試圖像的類別標籤,將所述多張測試圖像輸入到所述第一分類模型中,得到每張測試圖像的預測結果,所述電腦設備將所述預測結果與對應的類別標籤進行比較,並將與所述對應的類別標籤相同的預測結果確定為目標結果,進一步地,所述電腦設備將所述目標結果對應的測試圖像確定為所述目標圖像,更進一步地,所述電腦設備統計多張所述目標圖像的第一數量及所述多張測試圖像的第二數量,更進一步地,所述電腦設備計算所述第一數量在所述第二數量中所佔的比率,得到所述預測正確率。 In at least one embodiment of the present application, the computer device calculating the prediction accuracy of the first classification model for the multiple test images includes: the computer device obtains category labels of the multiple test images. , input the plurality of test images into the first classification model to obtain the prediction result of each test image, and the computer device compares the prediction result with the corresponding category label, and compares the prediction result with the corresponding category label. The prediction result with the same corresponding category label is determined as the target result. Further, the computer device determines the test image corresponding to the target result as the target image. Furthermore, the computer device counts multiple images. The first number of target images and the second number of the plurality of test images. Furthermore, the computer device calculates the ratio of the first number to the second number to obtain the The prediction accuracy rate.
透過上述實施方式,統計所述目標圖像的第一數量及所述多張測試圖像的第二數量,計算出所述第一數量在所述第二數量中的佔比,能夠快速地計算出所述第一分類模型的預測正確率。 Through the above implementation, the first number of target images and the second number of the plurality of test images are counted, and the proportion of the first number in the second number is calculated, which can quickly calculate Get the prediction accuracy of the first classification model.
步驟104,若所述預測正確率小於預設值,從所述多張測試圖像中選取目標圖像對所述第一分類模型進行調整,得到第二分類模型,其中,所述第二分類模型包括壓平層、全連接層及分類層。 Step 104: If the prediction accuracy rate is less than the preset value, select a target image from the plurality of test images to adjust the first classification model to obtain a second classification model, wherein the second classification model The model includes flattening layer, fully connected layer and classification layer.
在本申請的至少一個實施例中,所述目標圖像是指所述第一分類 模型對所述多張測試圖像在預測準確時所對應的一部分測試圖像。 In at least one embodiment of the present application, the target image refers to the first category A part of the test images corresponding to when the model accurately predicts the multiple test images.
在本申請的至少一個實施例中,所述電腦設備從所述多張測試圖像中選取目標圖像對所述第一分類模型進行調整,得到第二分類模型包括:所述電腦設備對多張所述目標圖像進行聚類處理,生成多個聚類中心,進一步地,所述電腦設備將每個聚類中心對應的目標圖像輸入到所述第一分類模型中進行訓練,直至所述預測正確率大於或者等於所述預設值,得到所述第二分類模型。 In at least one embodiment of the present application, the computer device selects a target image from the plurality of test images to adjust the first classification model. Obtaining the second classification model includes: the computer device selects a target image from the plurality of test images and adjusts the first classification model. The target image is subjected to clustering processing to generate multiple clustering centers. Further, the computer device inputs the target image corresponding to each clustering center into the first classification model for training. If the prediction accuracy rate is greater than or equal to the preset value, the second classification model is obtained.
其中,本實施例基於K均值聚類演算法(k means clustering algorithm)對多張所述目標圖像進行聚類處理,生成多個聚類中心。所述預設值可以自行設置,本申請不作限制。 Among them, this embodiment performs clustering processing on multiple target images based on a K means clustering algorithm to generate multiple clustering centers. The preset value can be set by oneself and is not limited in this application.
透過上述實施方式,使用聚類演算法選取出所述目標圖像對所述第一分類模型進行調整,直至所述第一分類模型的預測準確率大於所述預設值,得到所述第二分類模型,能夠提高所述第二分類模型的預測準確性,由於所述目標圖像均為分類正確的測試圖像,因此使用所述目標圖像進行調整能夠提高所述第二分類模型的分類能力。 Through the above implementation, a clustering algorithm is used to select the target image and adjust the first classification model until the prediction accuracy of the first classification model is greater than the preset value, and the second classification model is obtained. The classification model can improve the prediction accuracy of the second classification model. Since the target images are all correctly classified test images, adjustment using the target image can improve the classification of the second classification model. ability.
在本申請的其他實施例中,若所述聚類中心中包含任一目標圖像,則將該任一目標圖像輸入到所述第一分類模型中進行訓練,若所述聚類中心中不包含任一目標圖像,則將距離該聚類中心最近的目標圖像輸入到所述第一分類模型中進行訓練。在本申請的其他實施例中,在使用每個聚類中心對應的目標圖像對所述第一分類模型進行調整後,當調整後的第一分類模型無法大於或者等於所述預設值時,需要將所述多張目標圖像進行重新聚類,以生成多個新的聚類中心對所述第一分類模型進行重新訓練。 In other embodiments of the present application, if any target image is included in the clustering center, then any target image is input into the first classification model for training. If the clustering center contains If no target image is included, the target image closest to the cluster center is input into the first classification model for training. In other embodiments of the present application, after adjusting the first classification model using the target image corresponding to each cluster center, when the adjusted first classification model cannot be greater than or equal to the preset value , it is necessary to re-cluster the multiple target images to generate multiple new clustering centers to retrain the first classification model.
步驟105,將所述待分類圖像輸入到所述第二分類模型中,並獲取從所述壓平層輸出的初始特徵矩陣。 Step 105: Input the image to be classified into the second classification model, and obtain the initial feature matrix output from the flattening layer.
在本申請的至少一個實施例中,所述初始特徵矩陣是指經過所述壓平層進行降維操作後所得到的矩陣。 In at least one embodiment of the present application, the initial feature matrix refers to a matrix obtained after a dimension reduction operation by the flattening layer.
在本申請的至少一個實施例中,所述第二分類模型包括卷積層,
所述電腦設備將所述待分類圖像輸入到所述第二分類模型中,並獲取從所述壓平層輸出的初始特徵矩陣包括:所述電腦設備將所述待分類圖像輸入到所述卷積層中進行特徵提取,得到目標矩陣,將所述目標矩陣的多個維度值進行相乘運算,得到運算結果,將數值1作為矩陣行數,並將所述運算結果作為矩陣列數,基於所述矩陣行數及所述矩陣列數,將所述目標矩陣變換為所述初始特徵矩陣,所述初始特徵矩陣的維度為二維。
In at least one embodiment of the present application, the second classification model includes a convolutional layer,
The computer device inputs the image to be classified into the second classification model, and obtaining the initial feature matrix output from the flattening layer includes: the computer device inputs the image to be classified into the second classification model. Feature extraction is performed in the convolution layer to obtain a target matrix, multiple dimensional values of the target matrix are multiplied to obtain the operation result, the
其中,所述目標矩陣的維度大於或者等於3。所述初始特徵矩陣的生成過程與下文目標特徵矩陣的逆生成過程基本一致,本申請在此不作贅述。 Wherein, the dimension of the target matrix is greater than or equal to 3. The generation process of the initial feature matrix is basically the same as the inverse generation process of the target feature matrix below, and will not be described in detail here.
透過上述實施方式,將從所述卷積層中輸出的高維度的目標矩陣進行降維處理,得到所述初始特徵矩陣,透過降維操作,能夠控制所述初始特徵矩陣的維度大小。 Through the above implementation, the high-dimensional target matrix output from the convolution layer is subjected to dimensionality reduction processing to obtain the initial feature matrix. Through the dimensionality reduction operation, the dimension size of the initial feature matrix can be controlled.
步驟106,若所述初始特徵矩陣的維度小於所述全連接層中的初始權重矩陣的維度,對所述初始特徵矩陣進行升維處理,得到目標特徵矩陣。 Step 106: If the dimension of the initial feature matrix is smaller than the dimension of the initial weight matrix in the fully connected layer, perform dimensionality enhancement processing on the initial feature matrix to obtain a target feature matrix.
在本申請的至少一個實施例中,所述目標特徵矩陣是指維度與所述初始權重矩陣的維度一致的矩陣。 In at least one embodiment of the present application, the target feature matrix refers to a matrix whose dimensions are consistent with those of the initial weight matrix.
在本申請的至少一個實施例中,所述電腦設備對所述初始特徵矩陣進行升維處理,得到目標特徵矩陣包括:所述電腦設備統計所述初始特徵矩陣的所述矩陣行數及所述矩陣列數,進一步地,所述電腦設備將所述矩陣行數與所述矩陣列數進行相乘運算,得到目標乘積,將所述目標乘積進行質因數分解,得到多個質因數,更進一步地,所述電腦設備將所述多個質因數中相同的任意兩個質因數組合成質因數對,並計算所述質因數對中兩個質因數的乘積,得到特徵乘積,每個質因數只能組合一次,所述電腦設備根據所述目標乘積及所述特徵乘積從所述質因數對中選取目標質因數對,進一步地,所述電腦設備提取所述目標質因數對中的一個質因數,得到特徵質因數,所述電腦設備根據所述目標質因數對的對數及所述特徵質因數生成特徵數值,所述電腦設備在所述多個質因數中將所述目標質因數對替換為零,在完成替換後將所有不為零的 質因數進行相乘運算,得到目標數值,所述電腦設備基於配置值、所述目標數值及所述特徵數值,對所述初始特徵矩陣進行升維處理,得到所述目標特徵矩陣。 In at least one embodiment of the present application, the computer device performs dimensionality enhancement processing on the initial feature matrix, and obtaining the target feature matrix includes: the computer device counts the number of matrix rows of the initial feature matrix and the The number of matrix columns, further, the computer device multiplies the matrix row number and the matrix column number to obtain a target product, and performs prime factor decomposition on the target product to obtain multiple prime factors, and further Specifically, the computer device combines any two identical prime factors among the plurality of prime factors into a pair of prime factors, and calculates the product of the two prime factors in the pair of prime factors to obtain a characteristic product, each prime factor It can only be combined once. The computer device selects a target prime factor pair from the prime factor pair according to the target product and the characteristic product. Further, the computer device extracts one prime factor from the target prime factor pair. factor to obtain a characteristic prime factor, the computer device generates a characteristic value according to the logarithm of the target prime factor pair and the characteristic prime factor, the computer device replaces the target prime factor pair among the plurality of prime factors is zero, after completing the replacement, all non-zero The prime factors are multiplied together to obtain the target value. Based on the configuration value, the target value and the feature value, the computer device performs a dimension-raising process on the initial feature matrix to obtain the target feature matrix.
其中,所述目標質因數對是指該特徵乘積能被所述目標乘積整除的質因數對,所述配置值為數值1。可以理解的是,所述目標乘積足夠大且非質數以確保所述多個質因數中一定會存在至少兩個相同的質因數。 Wherein, the target prime factor pair refers to a prime factor pair whose characteristic product can be divided by the target product, and the configuration value is a value of 1. It can be understood that the target product is large enough and non-prime to ensure that there must be at least two identical prime factors among the plurality of prime factors.
具體地,所述電腦設備根據所述目標質因數對的對數及所述特徵質因數生成特徵數值包括:若所述目標質因數對的數量為單個,所述電腦設備將所述特徵質因數確定為所述特徵數值,若所述目標質因數對的數量為多個,所述電腦設備將所述特徵質因數進行相乘運算,得到所述特徵數值。 Specifically, the computer device generating a characteristic value based on the logarithm of the target prime factor pair and the characteristic prime factor includes: if the number of the target prime factor pair is single, the computer device determines the characteristic prime factor. is the characteristic value. If the number of target prime factor pairs is multiple, the computer device multiplies the characteristic prime factors to obtain the characteristic value.
具體地,所述電腦設備基於配置值、所述目標數值及所述特徵數值,對所述初始特徵矩陣進行升維處理,得到所述目標特徵矩陣包括:所述電腦設備將所述配置值作為批量大小,將所述目標數值作為通道數,將所述特徵數值作為行數及列數。 Specifically, the computer device performs dimensionality enhancement processing on the initial feature matrix based on the configuration value, the target value and the feature value. Obtaining the target feature matrix includes: the computer device uses the configuration value as For the batch size, use the target value as the number of channels and the feature value as the number of rows and columns.
例如:所述初始特徵矩陣的矩陣行數為1,所述初始特徵矩陣的矩陣列數為60,即:所述初始特徵矩陣為:[1 1 1 1 1 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 2 2 2 2 2]。 For example: the number of matrix rows of the initial feature matrix is 1, and the number of matrix columns of the initial feature matrix is 60, that is: the initial feature matrix is: [1 1 1 1 1 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 2 2 2 2 2].
所述配置值為1,透過上述方法計算得到所述目標數值為15,所述特徵數值為2,基於所述配置值1、所述目標數值15,所述特徵數值2將所述初始特徵矩陣進行升維處理,得到所述目標特徵矩陣,所述目標特徵矩陣為:
所述目標特徵矩陣中包含一個三維矩陣,即,所述三維矩陣中包括15個二維矩陣,每個二維矩陣的行數及列數均為2。本實施例中,當所述全 連接層中初始權重矩陣的維度為四維時,透過將所述初始特徵矩陣的維度統一轉換為四維,能夠確保輸入全連接層的目標特徵矩陣的維度與所述初始權重矩陣一致。 The target feature matrix includes a three-dimensional matrix, that is, the three-dimensional matrix includes 15 two-dimensional matrices, and the number of rows and columns of each two-dimensional matrix is both 2. In this embodiment, when all When the dimensions of the initial weight matrix in the connection layer are four dimensions, by uniformly converting the dimensions of the initial feature matrix into four dimensions, it can be ensured that the dimensions of the target feature matrix input to the fully connected layer are consistent with the initial weight matrix.
透過上述實施方式,將所述初始特徵矩陣的維度轉換為與所述初始權重矩陣的維度一致,使得所述目標特徵矩陣能夠與初始權重矩陣直接進行相乘運算,從而能夠將所述目標特徵矩陣中的多個二維矩陣加入運算,由於增加了每次運算的參數量,因此能夠提高所述全連接層的運算速度。 Through the above implementation, the dimensions of the initial feature matrix are converted to be consistent with the dimensions of the initial weight matrix, so that the target feature matrix can be directly multiplied with the initial weight matrix, so that the target feature matrix can be Multiple two-dimensional matrices are added to the operation, and the amount of parameters in each operation is increased, so the operation speed of the fully connected layer can be improved.
步驟107,將所述初始權重矩陣中的元素進行重新排列,得到目標權重矩陣。 Step 107: Rearrange the elements in the initial weight matrix to obtain a target weight matrix.
在本申請的至少一個實施例中,所述目標權重矩陣是指元素被重新排列後的矩陣。 In at least one embodiment of the present application, the target weight matrix refers to a matrix after elements are rearranged.
在本申請的至少一個實施例中,所述電腦設備將所述初始權重矩陣中的元素進行重新排列,得到目標權重矩陣包括:所述電腦設備將所述初始權重矩陣中每列的最後一個元素確定為目標元素,進一步地,所述電腦設備重複將每列的列首位置的元素調整到每列的列尾位置,每列其它元素的位置依序向列首位置移動,直到所述目標元素移動到列首位置後停止排列,得到所述目標權重矩陣。 In at least one embodiment of the present application, the computer device rearranges the elements in the initial weight matrix to obtain the target weight matrix, including: the computer device rearranges the last element of each column in the initial weight matrix Determined as the target element, further, the computer device repeatedly adjusts the element at the head position of each column to the end position of each column, and moves the positions of other elements in each column to the head position in sequence until the target element Stop the arrangement after moving to the head position of the column, and obtain the target weight matrix.
透過上述實施方式,能夠將所述初始權重矩陣中的所有元素進行重新排列,使得所述初始權重矩陣中元素的運算順序,更有利於與所述目標特徵矩陣進行快速相乘運算。 Through the above implementation, all elements in the initial weight matrix can be rearranged, so that the order of operations of the elements in the initial weight matrix is more conducive to fast multiplication operations with the target feature matrix.
步驟108,根據所述目標權重矩陣及所述目標特徵矩陣生成目標向量。 Step 108: Generate a target vector according to the target weight matrix and the target feature matrix.
在本申請的至少一個實施例中,所述目標向量是指所述目標權重矩陣與所述目標特徵矩陣的相乘結果。 In at least one embodiment of the present application, the target vector refers to the multiplication result of the target weight matrix and the target feature matrix.
在本申請的至少一個實施例中,所述電腦設備根據所述目標權重矩陣及所述目標特徵矩陣生成目標向量包括:所述電腦設備將所述目標權重矩 陣與所述目標特徵矩陣進行相乘運算,得到所述目標向量。 In at least one embodiment of the present application, the computer device generating a target vector according to the target weight matrix and the target feature matrix includes: the computer device converts the target weight matrix into The matrix is multiplied by the target feature matrix to obtain the target vector.
透過上述實施方式,由於改變了所述目標權重矩陣中的元素的運算順序,因此在每次運算時,能夠確保所述目標特徵矩陣中的元素在所述目標權重矩陣中都能夠有對應的元素與之運算,提高了運算的有效性,降低運算時間。 Through the above implementation, since the operation order of the elements in the target weight matrix is changed, it can be ensured that the elements in the target feature matrix have corresponding elements in the target weight matrix during each operation. Operating with it improves the effectiveness of the operation and reduces the operation time.
步驟109,將所述目標向量輸入到所述分類層中,得到所述待分類圖像的分類結果。 Step 109: Input the target vector into the classification layer to obtain the classification result of the image to be classified.
在本申請的至少一個實施例中,所述分類結果是指所述第二分類模型對所述待分類圖像的預測類別。所述分類結果可以包括:貓、狗等類別。 In at least one embodiment of the present application, the classification result refers to the predicted category of the image to be classified by the second classification model. The classification results may include categories such as cats and dogs.
在本申請的至少一個實施例中,所述電腦設備將所述目標向量輸入到所述分類層中,得到所述待分類圖像的分類結果包括:所述電腦設備將所述目標向量輸入到所述分類層中,得到每個類別的概率,所述電腦設備將取值最大的概率所對應的類別作為所述分類結果。其中,所述分類層可以為softmax分類器。 In at least one embodiment of the present application, the computer device inputs the target vector into the classification layer, and obtaining the classification result of the image to be classified includes: the computer device inputs the target vector into In the classification layer, the probability of each category is obtained, and the computer device uses the category corresponding to the probability with the largest value as the classification result. Wherein, the classification layer may be a softmax classifier.
透過將取值最大的概率所對應的類別確定為所述分類結果,能夠提高分類結果的準確性。 By determining the category corresponding to the probability with the largest value as the classification result, the accuracy of the classification result can be improved.
由以上技術方案可以看出,本申請透過計算所述第一分類模型對所述多張測試圖像的預測正確率,進而將所述預測準確率與所述預設值進行比較以確定是否要對所述第一分類模型進行調整,能夠提高所述第二分類模型的預測能力,由於在調整過程中只選取了目標圖像對所述第一分類模型進行調整,能夠降低調整過程中的運算量,從而提高所述第二分類模型的生成效率,將所述待分類圖像輸入所述第二分類模型中,並獲取從壓平層輸出的初始特徵矩陣,若所述初始特徵矩陣的維度小於所述全連接層中的初始權重矩陣的維度,則對所述初始特徵矩陣進行升維處理,得到目標特徵矩陣,透過改變所述目標特徵矩陣的維度,能夠增加每次運算的參數量,獲取全連接層的初始權重矩陣,並將所述初始權重矩陣的元素進行重新排列,得到所述目標權重矩陣,將所述目 標權重矩陣與所述目標特徵矩陣進行乘累加運算,得到目標向量,並將所述目標向量輸入到所述分類層中,得到所述待分類圖像的分類結果,由於將所述初始權重矩陣中的元素進行重新排列後改變了元素的運算順序,因此能夠確保每次運算時都會有權重矩陣中的元素參與運算,進而能夠避免輸出空白結果(即避免進行無效運算),從而能夠減少運算的次數及運算所用的時間,因此能夠加快圖像分類的速度。 It can be seen from the above technical solutions that this application calculates the prediction accuracy rate of the first classification model for the plurality of test images, and then compares the prediction accuracy rate with the preset value to determine whether to Adjusting the first classification model can improve the prediction ability of the second classification model. Since only the target image is selected to adjust the first classification model during the adjustment process, the calculation time during the adjustment process can be reduced. quantity, thereby improving the generation efficiency of the second classification model, input the image to be classified into the second classification model, and obtain the initial feature matrix output from the flattening layer, if the dimensions of the initial feature matrix is smaller than the dimension of the initial weight matrix in the fully connected layer, then the initial feature matrix is dimensioned to obtain a target feature matrix. By changing the dimension of the target feature matrix, the amount of parameters in each operation can be increased, Obtain the initial weight matrix of the fully connected layer, and rearrange the elements of the initial weight matrix to obtain the target weight matrix, and put the target weight matrix into The weight matrix and the target feature matrix are multiplied and accumulated to obtain a target vector, and the target vector is input into the classification layer to obtain the classification result of the image to be classified. Since the initial weight matrix is The elements in are rearranged and the order of operations of the elements is changed. Therefore, it is ensured that the elements in the weight matrix will participate in the operation in each operation, thereby avoiding the output of blank results (that is, avoiding invalid operations), thus reducing the cost of operations. The number of times and the time used for operations can therefore speed up image classification.
如圖3所示,是本申請實現圖像分類方法的較佳實施例的電腦設備的結構示意圖。 As shown in Figure 3, it is a schematic structural diagram of a computer device for implementing an image classification method according to a preferred embodiment of the present application.
在本申請的一個實施例中,所述電腦設備1包括,但不限於,儲存器12、處理器13,以及儲存在所述儲存器12中並可在所述處理器13上運行的電腦程式,例如圖像分類程式。本領域技術人員可以理解,所述示意圖僅僅是電腦設備1的示例,並不構成對電腦設備1的限定,可以包括比圖示更多或更少的部件,或者組合某些部件,或者不同的部件,例如所述電腦設備1還可以包括輸入輸出設備、網路接入設備、匯流排等。
In one embodiment of the present application, the
所述處理器13可以是中央處理單元(Central Processing Unit,CPU),還可以是其他通用處理器、數位訊號處理器(Digital Signal Processor,DSP)、專用積體電路(Application Specific Integrated Circuit,ASIC)、現場可程式設計閘陣列(Field-Programmable Gate Array,FPGA)或者其他可程式設計邏輯器件、分立元器件門電路或者電晶體組件、分立硬體組件等。通用處理器可以是微處理器或者該處理器也可以是任何常規的處理器等,所述處理器13是所述電腦設備1的運算核心和控制中心,利用各種介面和線路連接整個電腦設備1的各個部分,及獲取所述電腦設備1的作業系統以及安裝的各類應用程式、程式碼等。例如,所述處理器13可以透過介面獲取所述拍攝設備2拍攝到的所述待分類圖像。
The
所述處理器13獲取所述電腦設備1的作業系統以及安裝的各類應用程式。所述處理器13獲取所述應用程式以實現上述各個圖像分類方法實施
例中的步驟,例如圖2所示的步驟。
The
示例性的,所述電腦程式可以被分割成一個或多個模組/單元,所述一個或者多個模組/單元被儲存在所述儲存器12中,並由所述處理器13獲取,以完成本申請。所述一個或多個模組/單元可以是能夠完成特定功能的一系列電腦程式指令段,該指令段用於描述所述電腦程式在所述電腦設備1中的獲取過程。
For example, the computer program may be divided into one or more modules/units, and the one or more modules/units are stored in the
所述儲存器12可用於儲存所述電腦程式和/或模組,所述處理器13透過運行或獲取儲存在所述儲存器12內的電腦程式和/或模組,以及調用儲存在儲存器12內的資料,實現所述電腦設備1的各種功能。所述儲存器12可主要包括儲存程式區和儲存資料區,其中,儲存程式區可儲存作業系統、至少一個功能所需的應用程式(比如聲音播放功能、圖像播放功能等)等;儲存資料區可儲存根據電腦設備的使用所創建的資料等。此外,儲存器12可以包括非易失性儲存器,例如硬碟、記憶體(memory)、插接式硬碟,智慧儲存卡(Smart Media Card,SMC),安全數位(Secure Digital,SD)卡,記憶卡(Flash Card)、至少一個磁碟儲存器件、記憶器件、或其他非易失性固態儲存器件。
The
所述儲存器12可以是電腦設備1的外部儲存器和/或內部儲存器。進一步地,所述儲存器12可以是具有實物形式的儲存器,如記憶條、TF卡(Trans-flash Card)等等。
The
所述電腦設備1集成的模組/單元如果以軟體功能單元的形式實現並作為獨立的產品銷售或使用時,可以儲存在一個電腦可讀取儲存介質中。基於這樣的理解,本申請實現上述實施例方法中的全部或部分流程,也可以透過電腦程式來指令相關的硬體來完成,所述的電腦程式可儲存於一電腦可讀儲存介質中,該電腦程式在被處理器獲取時,可實現上述各個方法實施例的步驟。
If the integrated modules/units of the
其中,所述電腦程式包括電腦程式代碼,所述電腦程式代碼可以為原始程式碼形式、物件代碼形式、可獲取檔或某些中間形式等。所述電腦可讀介質可以包括:能夠攜帶所述電腦程式代碼的任何實體或裝置、記錄介質、 隨身碟、移動硬碟、磁碟、光碟、電腦儲存器、唯讀記憶體(ROM,Read-Only Memory)。 Wherein, the computer program includes computer program code, and the computer program code can be in the form of original program code, object code form, obtainable file or some intermediate form, etc. The computer-readable medium may include: any entity or device, recording medium, or device capable of carrying the computer program code. Pen drives, mobile hard drives, magnetic disks, optical disks, computer storage, read-only memory (ROM, Read-Only Memory).
結合圖2,所述電腦設備1中的所述儲存器12儲存多個指令以實現一種圖像分類方法,所述處理器13可獲取所述多個指令從而實現:獲取分類網路,並獲取待分類圖像、訓練圖像及多張測試圖像;基於所述訓練圖像對所述分類網路進行訓練,得到第一分類模型;計算所述第一分類模型對所述多張測試圖像的預測正確率;若所述預測正確率小於預設值,從所述多張測試圖像中選取目標圖像對所述第一分類模型進行調整,得到第二分類模型,其中,所述第二分類模型包括壓平層、全連接層及分類層;將所述待分類圖像輸入到所述第二分類模型中,並獲取從所述壓平層輸出的初始特徵矩陣;若所述初始特徵矩陣的維度小於所述全連接層中的初始權重矩陣的維度,對所述初始特徵矩陣進行升維處理,得到目標特徵矩陣;將所述初始權重矩陣中的元素進行重新排列,得到目標權重矩陣;根據所述目標權重矩陣及所述目標特徵矩陣生成目標向量;將所述目標向量輸入到所述分類層中,得到所述待分類圖像的分類結果。
2 , the
具體地,所述處理器13對上述指令的具體實現方法可參考圖2對應實施例中相關步驟的描述,在此不贅述。
Specifically, for the specific implementation method of the above instructions by the
在本申請所提供的幾個實施例中,應該理解到,所揭露的系統,裝置和方法,可以透過其它的方式實現。例如,以上所描述的裝置實施例僅僅是示意性的,例如,所述模組的劃分,僅僅為一種邏輯功能劃分,實際實現時可以有另外的劃分方式。 In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of modules is only a logical function division, and there may be other division methods in actual implementation.
所述作為分離部件說明的模組可以是或者也可以不是物理上分開的,作為模組顯示的部件可以是或者也可以不是物理單元,即可以位於一個地方,或者也可以分佈到多個網路單元上。可以根據實際的需要選擇其中的部分或者全部模組來實現本實施例方案的目的。 The modules described as separate components may or may not be physically separated. The components shown as modules may or may not be physical units, that is, they may be located in one place, or they may be distributed to multiple networks. on the unit. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本申請各個實施例中的各功能模組可以集成在一個處理 單元中,也可以是各個單元單獨物理存在,也可以兩個或兩個以上單元集成在一個單元中。上述集成的單元既可以採用硬體的形式實現,也可以採用硬體加軟體功能模組的形式實現。 In addition, each functional module in each embodiment of the present application can be integrated into one processing In a unit, each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of hardware plus software function modules.
因此,無論從哪一點來看,均應將實施例看作是示範性的,而且是非限制性的,本申請的範圍由所附請求項而不是上述說明限定,因此旨在將落在請求項的等同要件的含義和範圍內的所有變化涵括在本申請內。不應將請求項中的任何附關聯圖標記視為限制所涉及的請求項。 Therefore, the embodiments should be regarded as illustrative and non-restrictive from any point of view, and the scope of the present application is defined by the appended claims rather than the above description, and it is therefore intended that those falling within the claims All changes within the meaning and scope of the equivalent elements are included in this application. Any associated association markup in a request item should not be considered to limit the request item in question.
此外,顯然“包括”一詞不排除其他單元或步驟,單數不排除複數。本申請中陳述的多個單元或裝置也可以由一個單元或裝置透過軟體或者硬體來實現。第一、第二等詞語用來表示名稱,而並不表示任何特定的順序。 Furthermore, it is clear that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. Multiple units or devices stated in this application may also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names and do not indicate any specific order.
最後應說明的是,以上實施例僅用以說明本申請的技術方案而非限制,儘管參照較佳實施例對本申請進行了詳細說明,本領域的普通技術人員應當理解,可以對本申請的技術方案進行修改或等同替換,而不脫離本申請技術方案的精神和範圍。 Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not limiting. Although the present application has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present application can be modified. Modifications or equivalent substitutions may be made without departing from the spirit and scope of the technical solution of the present application.
101~109:步驟 101~109: Steps
Claims (9)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW111140738A TWI824796B (en) | 2022-10-26 | 2022-10-26 | Method for classifying images, computer device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW111140738A TWI824796B (en) | 2022-10-26 | 2022-10-26 | Method for classifying images, computer device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
TWI824796B true TWI824796B (en) | 2023-12-01 |
TW202418215A TW202418215A (en) | 2024-05-01 |
Family
ID=90053058
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
TW111140738A TWI824796B (en) | 2022-10-26 | 2022-10-26 | Method for classifying images, computer device and storage medium |
Country Status (1)
Country | Link |
---|---|
TW (1) | TWI824796B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TWI691930B (en) * | 2018-09-19 | 2020-04-21 | 財團法人工業技術研究院 | Neural network-based classification method and classification device thereof |
TW202139131A (en) * | 2020-03-23 | 2021-10-16 | 以色列商奧寶科技有限公司 | Adaptive learning for image classification |
TW202209251A (en) * | 2020-08-20 | 2022-03-01 | 美商高通公司 | Image processing based on object categorization |
TWI757668B (en) * | 2019-01-15 | 2022-03-11 | 中國大陸商北京市商湯科技開發有限公司 | Network optimization method and device, image processing method and device, storage medium |
TW202219891A (en) * | 2020-11-06 | 2022-05-16 | 瑞昱半導體股份有限公司 | Image processing method and image processing system |
-
2022
- 2022-10-26 TW TW111140738A patent/TWI824796B/en active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TWI691930B (en) * | 2018-09-19 | 2020-04-21 | 財團法人工業技術研究院 | Neural network-based classification method and classification device thereof |
TWI757668B (en) * | 2019-01-15 | 2022-03-11 | 中國大陸商北京市商湯科技開發有限公司 | Network optimization method and device, image processing method and device, storage medium |
TW202139131A (en) * | 2020-03-23 | 2021-10-16 | 以色列商奧寶科技有限公司 | Adaptive learning for image classification |
TW202209251A (en) * | 2020-08-20 | 2022-03-01 | 美商高通公司 | Image processing based on object categorization |
TW202219891A (en) * | 2020-11-06 | 2022-05-16 | 瑞昱半導體股份有限公司 | Image processing method and image processing system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Li et al. | Few-shot cotton pest recognition and terminal realization | |
Lu et al. | Rating image aesthetics using deep learning | |
CN110209867A (en) | Training method, device, equipment and the storage medium of image encrypting algorithm | |
CN106845621A (en) | Dense population number method of counting and system based on depth convolutional neural networks | |
US11347308B2 (en) | Method and apparatus with gaze tracking | |
CN103838570B (en) | Information processing apparatus, control method therefor, and electronic device | |
CN111898703B (en) | Multi-label video classification method, model training method, device and medium | |
DE102021107586A1 (en) | SPECULATIVE TRAINING USING PARTIAL GRADIENT UPDATE | |
US20220327769A1 (en) | Neural light transport | |
CN109817338A (en) | A kind of chronic disease aggravates risk assessment and warning system | |
Li et al. | Spatial dynamic graph convolutional network for traffic flow forecasting | |
WO2020062299A1 (en) | Neural network processor, data processing method and related device | |
CN112102165A (en) | Light field image angular domain super-resolution system and method based on zero sample learning | |
WO2015143985A1 (en) | Result vector determining method and apparatus | |
CN116187430A (en) | Federal learning method and related device | |
Wu et al. | Research on recognition method of leaf diseases of woody fruit plants based on transfer learning | |
TWI824796B (en) | Method for classifying images, computer device and storage medium | |
Plum et al. | replicAnt: a pipeline for generating annotated images of animals in complex environments using Unreal Engine | |
CN111126501B (en) | Image identification method, terminal equipment and storage medium | |
DE112020006070T5 (en) | HARDWARE ACCELERATOR WITH RECONFIGURABLE INSTRUCTION SET | |
Wu et al. | Image classification method rationally utilizing spatial information of the image | |
WO2020151247A1 (en) | Image analysis method and system | |
TW202418215A (en) | Method for classifying images, computer device and storage medium | |
US20240144649A1 (en) | Image classification method, electronic device and storage medium | |
TWI814623B (en) | Method for identifying images, computer device and storage medium |