'int' 对象不可订阅:Python 中的 HOG SVM 对象检测
'int' object is not subscriptable : HOG SVM object detection in Python
我正在做一个对象检测项目,同时使用 HOG skimage 和 SVM。我正在努力
使用我训练的 SVM 模型将我所有的正面 windows 保存在列表中,但我遇到了一个错误:
'int' 对象不可在此行订阅:detect = model_.predict([features_window[i]])
def detection_image(image):
coordonnees,HOG_features = fenetre_coulissante_HOG(image)
features_window = []
#We will now loop through all the features collected by the HOG on each of the sliding windows
#We will predict from our model whether we consider the window as positive or negative: whether or not it contains our object
for features_window in range(len(HOG_features)):
#For all the windows considered positive of our model we will record their coordinates
detect = model_.predict([features_window[i]])
if detect[0] == 1:
features_window.append((coordonnees[:i]))
return features_window
问题出在那一行:
for features_window in range(len(HOG_features))
在循环内部,它会将 features
变量变成一个整数,而不是原来的列表。如果改成for i in ...
会解决问题,但是features_window[i]
会出问题,因为features_window
是一个空集合;也许您打算改用 HOG_features[i]
?
我正在做一个对象检测项目,同时使用 HOG skimage 和 SVM。我正在努力
使用我训练的 SVM 模型将我所有的正面 windows 保存在列表中,但我遇到了一个错误:
'int' 对象不可在此行订阅:detect = model_.predict([features_window[i]])
def detection_image(image):
coordonnees,HOG_features = fenetre_coulissante_HOG(image)
features_window = []
#We will now loop through all the features collected by the HOG on each of the sliding windows
#We will predict from our model whether we consider the window as positive or negative: whether or not it contains our object
for features_window in range(len(HOG_features)):
#For all the windows considered positive of our model we will record their coordinates
detect = model_.predict([features_window[i]])
if detect[0] == 1:
features_window.append((coordonnees[:i]))
return features_window
问题出在那一行:
for features_window in range(len(HOG_features))
在循环内部,它会将 features
变量变成一个整数,而不是原来的列表。如果改成for i in ...
会解决问题,但是features_window[i]
会出问题,因为features_window
是一个空集合;也许您打算改用 HOG_features[i]
?