用戶上傳圖片時需要判斷這張圖是否屬于某類圖片,比如飛機。我找到的示例是一個圖片分類器,比如訓練三個分類飛機、汽車、摩托,然后上傳一張圖片判斷這張圖片最接近哪一類。但是我并不確定用戶會上傳什么上來,比如我自己測試上傳了一張貓,而回顯的答案是飛機。顯然我不可能訓練所有圖片分類,這也不符合我們的需求。希望能只訓練飛機一個分類,然后上傳圖片時判斷是或否。示例中的代碼是用了sckikit-learn的極限森林算法聚類,但我查了這個api,沒有找到合用的方法.MethodsMethods
fit(X[, y]) Compute k-means clustering.
fit_predict(X[, y]) Compute cluster centers and predict cluster index for each sample.
fit_transform(X[, y]) Compute clustering and transform X to cluster-distance space.
get_params([deep]) Get parameters for this estimator.
predict(X) Predict the closest cluster each sample in X belongs to.
score(X[, y]) Opposite of the value of X on the K-means objective.
set_params(**params) Set the parameters of this estimator.
transform(X) Transform X to a cluster-distance space.請問應該怎么解決呢?
1 回答

手掌心
TA貢獻1942條經驗 獲得超3個贊
假如你訓練了飛機、汽車、摩托 三個分類,那么用戶傳圖片,你predict(X)得到應該是onehot的3個概率,你可以手動設置一下概率低于0.9或者某值時未識別。
- 1 回答
- 0 關注
- 911 瀏覽
添加回答
舉報
0/150
提交
取消