我遇到問題,我得到一組圖片並需要對這些圖片進行分類。將一組圖像分類爲
事情是,我真的沒有這些圖像的任何知識。所以我打算使用盡可能多的描述符,然後對這些描述符進行PCA處理,以便只識別對我有用的描述符。
我可以在很多數據點上進行監督學習,如果有幫助的話。但是,圖片之間有可能相互連接。這意味着從Image X到Image X + 1可能會有一個發展,儘管我希望能夠將每張圖片中的信息整理出來。
我的問題是:
- 使用Python時,我如何做到這一點最好的嗎? (我想首先在速度不成問題的情況下進行概念驗證)。我應該使用哪些庫?
- 是否有例子的圖像這樣的分類?使用一組描述符並通過PCA進行烹飪的示例?說實話,這部分對我來說有點嚇人。雖然我認爲python應該已經爲我做了這樣的事情。
編輯: 我發現我正在試圖走出這一個整潔套件:http://scikit-image.org/似乎有一些描述在那裏。有沒有辦法根據自己對目標分類的描述能力對特徵進行自動特徵提取和排名? PCA應該能夠自動排名。
編輯2: 我有我的數據存儲框架現在更精緻一點。我將使用Fat系統作爲數據庫。我將爲每個類的組合實例創建一個文件夾。因此,如果圖片屬於第1和第2類,將會有一個包含這些圖片的文件夾img12。這樣我可以更好地控制每個班級的數據量。
編輯3: 我找到了一個用於python的庫(sklearn)的例子,它執行某種我想要做的事情。它是關於識別手寫數字。我試圖將我的數據集轉換成我可以使用的東西。
這裏是我發現使用sklearn的例子:
import pylab as pl
# Import datasets, classifiers and performance metrics
from sklearn import datasets, svm, metrics
# The digits dataset
digits = datasets.load_digits()
# The data that we are interested in is made of 8x8 images of digits,
# let's have a look at the first 3 images, stored in the `images`
# attribute of the dataset. If we were working from image files, we
# could load them using pylab.imread. For these images know which
# digit they represent: it is given in the 'target' of the dataset.
for index, (image, label) in enumerate(zip(digits.images, digits.target)[:4]):
pl.subplot(2, 4, index + 1)
pl.axis('off')
pl.imshow(image, cmap=pl.cm.gray_r, interpolation='nearest')
pl.title('Training: %i' % label)
# To apply an classifier on this data, we need to flatten the image, to
# turn the data in a (samples, feature) matrix:
n_samples = len(digits.images)
data = digits.images.reshape((n_samples, -1))
# Create a classifier: a support vector classifier
classifier = svm.SVC(gamma=0.001)
# We learn the digits on the first half of the digits
classifier.fit(data[:n_samples/2], digits.target[:n_samples/2])
# Now predict the value of the digit on the second half:
expected = digits.target[n_samples/2:]
predicted = classifier.predict(data[n_samples/2:])
print("Classification report for classifier %s:\n%s\n"
% (classifier, metrics.classification_report(expected, predicted)))
print("Confusion matrix:\n%s" % metrics.confusion_matrix(expected, predicted))
for index, (image, prediction) in enumerate(
zip(digits.images[n_samples/2:], predicted)[:4]):
pl.subplot(2, 4, index + 5)
pl.axis('off')
pl.imshow(image, cmap=pl.cm.gray_r, interpolation='nearest')
pl.title('Prediction: %i' % prediction)
pl.show()
到目前爲止您嘗試了什麼?顯示一些努力隊友。 – 2013-05-03 14:02:45
我將編輯目前爲止完成的工作。 – tarrasch 2013-05-04 06:49:26