ahmetozlu / color_recognition

:art: Color recognition & classification & detection on webcam stream / on video / on single image using K-Nearest Neighbors (KNN) is trained with color histogram features by OpenCV.
https://youtu.be/05PYXwBw3Z0
MIT License
325 stars 122 forks source link

test.data, what is supposed to be? #4

Closed remic33 closed 3 years ago

remic33 commented 5 years ago

Hello @ahmetozlu Ahmetozlu, What is supposed to be inside the test.data file? You did not provide explanations about that file. I'm trying to implement your code after object detection, with numpy array and I have trouble like this :

` ~/Documents/Code/yolov3-tf2/yolov3_tf2/utils.py in color_recog(cropped_np)
    165         print('training data is ready, classifier is loading...')
    166 
--> 167     # get the prediction
    168     color_histogram_feature_extraction.color_histogram_of_test_image(cropped_np)
    169     prediction = knn_classifier.main('./data/training.data', './data/test.data')

~/Documents/Code/yolov3-tf2/yolov3_tf2/knn_classifier.py in main(training_data, test_data)
     74     k = 3  # K value of k nearest neighbor
     75     for x in range(len(test_feature_vector)):
---> 76         neighbors = kNearestNeighbors(training_feature_vector, test_feature_vector[x], k)
     77         result = responseOfNeighbors(neighbors)
     78         classifier_prediction.append(result)

~/Documents/Code/yolov3-tf2/yolov3_tf2/knn_classifier.py in kNearestNeighbors(training_feature_vector, testInstance, k)
     25     neighbors = []
     26     for x in range(k):
---> 27         neighbors.append(distances[x][0])
     28     return neighbors
     29 

IndexError: list index out of range

`

Thanks !

thatnealpatel commented 4 years ago

I also am getting a list index out of range

training data is ready, classifier is loading...
Traceback (most recent call last):
  File "src/color_classification_image.py", line 32, in <module>
    prediction = knn_classifier.main('training.data', 'test.data')
  File "/home/pi/Desktop/pi-projects/color_recognition/src/color_recognition_api/knn_classifier.py", line 87, in main
    return classifier_prediction[0]
IndexError: list index out of range
MrCuiHao commented 4 years ago

I solved this problem by changed the path of the train.data and test.data to absolute path