model = RandomForestClassifier(n_estimators=100, random_state=42)Ĭomplete error trace back: Traceback (most recent call last):įile "~/openCV/saliency_detection/svm_train.py", line 59, in įile "/usr/lib/python2.7/site-packages/sklearn/ensemble/forest.py", line 247, in fit and _labels are curresponding lables either 1 or 0, for each data(image) samples respectively. The error is throwned when RF classifier is set for training.here _data is a list of feature vectors( ~feat_vec~ ) that are computed previously. but only when all the three features stacked it geves the error. 0.Īs it can be seen the datatype and dimensions of all three arrays are same, but still getting the error while training with RF or SVC classifier, also when i don't use location feature and train only with color and histogram features, then it doesn't generate the error, and both the training and prediction program works fine. This is color feautre vector Īnd this is histogram feature vector [ 0. This is the first one, location feature [ 82. To trigger the error, but everything looks fine to me. In order to confirm the dtype, dimensions of array are not ambiguous Here i have manually cheked the elements in all three feature vectors, Pixel have two cordinates so, i flattened it, to form a array withįinally i stacked all the three features to form single feature vector, feat_vec = np.hstack().flatten() Here initially the cords represents to a array with depth 2 coz every Loc_feat = np.array(cords, dtype=np.float32).flatten() cords = for t in clusters_.get(disc)] # reversing the list of tuplesĭisc_pts = np.array(cords, dtype=np.int32) Hist = np.hstack()Īnd finally am using location features, by simply flattenedĭown the (x,y) cordinate list to form a feature array whhich will L_hist = np.array(l_hist, dtype=np.float32).flatten()Ī_hist = np.array(a_hist, dtype=np.float32).flatten()īb_hist = np.array(bb_hist, dtype=np.float32).flatten() S_hist = np.array(s_hist, dtype=np.float32).flatten() G_hist = np.array(g_hist, dtype=np.float32).flatten()ī_hist = np.array(b_hist, dtype=np.float32).flatten() R_hist = np.array(r_hist, dtype=np.float32).flatten() H_hist = np.array(h_hist, dtype=np.float32).flatten() L_hist = cv2.calcHist(,, mask, ,Ī_hist = cv2.calcHist(,, mask, ,īb_hist = cv2.calcHist(,, mask, , G_hist = cv2.calcHist(,, mask, ,ī_hist = cv2.calcHist(,, mask, , def compute_hist_feature(rgb_seg, hsv_seg, lab_seg, mask): asĮvery histogram here performed on single color channel, so depth ofĮvery histogram feature will always be 1. In the following function i only computed histogram values fromĭifferent color spaces again RGB,LAB,HSV color spaces used. Lbp = np.array(lbp, dtype=np.float32).flatten()Īvg_color = np.hstack() def extract_color_feature(rgb_roi, lab_roi, hsv_roi, gray_roi):Īvg_rgb_per_row = np.average(rgb_roi, axis=0)Īvg_rgb = np.average(avg_rgb_per_row, axis=0).flatten()Īvg_lab_per_row = np.average(lab_roi, axis=0)Īvg_lab = np.average(avg_lab_per_row, axis=0).flatten()Īvg_hs = np.hstack().flatten()Īvg_rgb = np.array(avg_rgb, dtype=np.float32).flatten()Īvg_lab = np.array(avg_lab, dtype=np.float32).flatten()Īvg_hs = np.array(avg_hs, dtype=np.float32).flatten() The possible feature vector array, from different color spaces. GRAY image respectively, as from the code below i have flattened all Of images in different color spaces,here am working on RGB,LAB,HSV and Here, am computing the color features by simply taking mean/average So am training a random forest classifier on 3 different features, all with different dimensions but i reshaped them to to (-1,1), which can fit for training the RF(random forest) model, but it keep on giving the same error again and again as i have tried all the possible things, here are the list of feature functions am using, i also checked, setting an array element with a sequence" error could be improved. Tried all the possible solutions with similar question here on stack,īut none of them worked. Before downvoting this question and marked as duplicate, let me just explain the issue, i
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |