OpenCV 4.12.0
開源計算機視覺
載入中...
搜尋中...
無匹配項
cv::dnn::ClassificationModel 類參考

此類表示分類模型的高階 API。 更多...

#include <opencv2/dnn/dnn.hpp>

cv::dnn::ClassificationModel 的協作圖

公共成員函式

 ClassificationModel (分類模型) ()
 
 ClassificationModel (const Net &network)
 從深度學習網路建立模型。
 
 ClassificationModel (CV_WRAP_FILE_PATH const String &model, CV_WRAP_FILE_PATH const String &config="")
 從以支援的格式之一表示的網路建立分類模型。 modelconfig 引數的順序無關緊要。
 
std::pair< int, float > classify (InputArray frame)
 給定 input 幀,建立輸入 blob,執行網路並返回 top-1 預測。
 
void classify (InputArray frame, int &classId, float &conf)
 
bool getEnableSoftmaxPostProcessing () const
 獲取啟用/停用 softmax 後處理選項。
 
ClassificationModelsetEnableSoftmaxPostProcessing (bool enable)
 設定啟用/停用 softmax 後處理選項。
 
- 從 cv::dnn::Model 繼承的公共成員函式
 Model (模型) ()
 
 Model (const Model &)=default
 
 Model (const Net &network)
 從深度學習網路建立模型。
 
 Model (CV_WRAP_FILE_PATH const String &model, CV_WRAP_FILE_PATH const String &config="")
 從以支援的格式之一表示的深度學習網路建立模型。 modelconfig 引數的順序無關緊要。
 
 Model (Model &&)=default
 
ModelenableWinograd (bool useWinograd)
 
Impl * getImpl () const
 
Impl & getImplRef () const
 
NetgetNetwork_ ()
 
NetgetNetwork_ () const
 
 operator Net & () const
 
Modeloperator= (const Model &)=default
 
Modeloperator= (Model &&)=default
 
void predict (InputArray frame, OutputArrayOfArrays outs) const
 給定 input 幀,建立輸入 blob,執行網路並返回輸出 blobs
 
ModelsetInputCrop (bool crop)
 設定幀的 crop 標誌。
 
ModelsetInputMean (const Scalar &mean)
 設定幀的均值。
 
void setInputParams (double scale=1.0, const Size &size=Size(), const Scalar &mean=Scalar(), bool swapRB=false, bool crop=false)
 設定幀的預處理引數。
 
ModelsetInputScale (const Scalar &scale)
 設定幀的 scalefactor 值。
 
ModelsetInputSize (const Size &size)
 設定幀的輸入大小。
 
ModelsetInputSize (int width, int height)
 
ModelsetInputSwapRB (bool swapRB)
 設定幀的 swapRB 標誌。
 
ModelsetOutputNames (const std::vector< String > &outNames)
 設定幀的輸出名稱。
 
ModelsetPreferableBackend (dnn::Backend backendId)
 
ModelsetPreferableTarget (dnn::Target targetId)
 

額外繼承的成員

- 從 cv::dnn::Model 繼承的保護屬性
Ptr< Impl > impl
 

詳細描述

此類表示分類模型的高階 API。

ClassificationModel 允許為預處理輸入影像設定引數。 ClassificationModel 從包含訓練權重和配置的檔案建立網路,設定預處理輸入,執行前向傳遞並返回 top-1 預測。

建構函式 & 解構函式文件

◆ ClassificationModel() [1/3]

cv::dnn::ClassificationModel::ClassificationModel ( )
Python
cv.dnn.ClassificationModel(model[, config]) -> <dnn_ClassificationModel 物件>
cv.dnn.ClassificationModel(網路) -> <dnn_ClassificationModel 物件>

◆ ClassificationModel() [2/3]

cv::dnn::ClassificationModel::ClassificationModel ( CV_WRAP_FILE_PATH const String & model,
CV_WRAP_FILE_PATH const String & config = "" )
Python
cv.dnn.ClassificationModel(model[, config]) -> <dnn_ClassificationModel 物件>
cv.dnn.ClassificationModel(網路) -> <dnn_ClassificationModel 物件>

從以支援的格式之一表示的網路建立分類模型。 modelconfig 引數的順序無關緊要。

引數
[輸入]model二進位制檔案包含訓練權重。
[輸入]config文字檔案包含網路配置。

◆ ClassificationModel() [3/3]

cv::dnn::ClassificationModel::ClassificationModel ( const Net & 網路)
Python
cv.dnn.ClassificationModel(model[, config]) -> <dnn_ClassificationModel 物件>
cv.dnn.ClassificationModel(網路) -> <dnn_ClassificationModel 物件>

從深度學習網路建立模型。

引數
[輸入]網路Net 物件。

成員函式文件

◆ classify() [1/2]

std::pair< int, float > cv::dnn::ClassificationModel::classify ( InputArray frame)
Python
cv.dnn.ClassificationModel.classify(frame) -> classId, conf

給定 input 幀,建立輸入 blob,執行網路並返回 top-1 預測。

引數
[輸入]frame輸入影像。

◆ classify() [2/2]

void cv::dnn::ClassificationModel::classify ( InputArray frame,
int & classId,
float & conf )
Python
cv.dnn.ClassificationModel.classify(frame) -> classId, conf

這是一個過載的成員函式,為了方便而提供。 它與上面的函式僅在於它接受的引數。

◆ getEnableSoftmaxPostProcessing()

bool cv::dnn::ClassificationModel::getEnableSoftmaxPostProcessing ( ) const
Python
cv.dnn.ClassificationModel.getEnableSoftmaxPostProcessing() -> retval

獲取啟用/停用 softmax 後處理選項。

此選項預設為 false,softmax 後處理未在 classify() 函式中應用。

◆ setEnableSoftmaxPostProcessing()

ClassificationModel & cv::dnn::ClassificationModel::setEnableSoftmaxPostProcessing ( bool 啟用)
Python
cv.dnn.ClassificationModel.setEnableSoftmaxPostProcessing(啟用) -> retval

設定啟用/停用 softmax 後處理選項。

如果此選項為 true,則在 classify() 函式中的前向推理之後應用 softmax,以將置信度範圍轉換為 [0.0-1.0]。 此函式允許您切換此行為。 如果模型中不包含 softmax 層,請設定為 true。

引數
[輸入]啟用classify() 函式中設定啟用 softmax 後處理。

此類文件由以下檔案生成