nickgillian / grt

gesture recognition toolkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DTW classifies only first class

BobbyCGD opened this issue · comments

commented

Hello, I am using DTW to recognise gestures performed with the Leap Motion, but I am getting some very strange behaviour. If I add only one class, It will work fine for the most part, but if I add two or more classes, things get messy. In the beginning, the training session would not complete at all. After I created a loop to reduce the size of the training data, and so I set the recording speed to 30fps which let me train the model. After that, though recognition is chaotic and unusable.

I have attached the TrainingData.txt file that I generate with the Leap. Do I have to process it in any way? And if so can you guide me where to look, please?

@BobbyCGD did you figure out the issue with only first class classification? I am facing the same issue.

Thanks for sharing your training data.

One thing I notice is that the length of your gestures is huge. Some gestures have only 22 samples, others have over 660. The DTW algorithm can handle some variation in the length of the gestures, but a difference of 30X will cause strange results.

Can you try recording a few examples again for each class, but try and make the length of each recording approximately the same. This quick experiment should at least tell you if the gestures can be detected with the current input features.

commented

@SurKM9 only just checked my emails, sorry for not getting back to you earlier. Please see below for more information on the problem.

@nickgillian Thanks for the hint, I am yet to experiment if this is the root cause of my misery, please see below.

Haha, glad you pointed that out. I think I got what the cause of my problem is.

Upon a second investigation of the training data, I noticed that every example starting from the first one to the last one has 22 more records than the previous one. I have indeed made sure that every sample is the same size by limiting the time for recording. However, it appears that I am not clearing something properly.

To clarify, Gesture 1 - Sample 1, has 22 frames, Gesture 1 - Sample 2 has 44 frames. The first 22 frames for sample 2 are the same as for sample 1. Taking this a step further, Gesture 2 - Sample 1, has n-number of frames (exact number not important) the first 22 frames, however, match the 22 frames from Gesture 1 - Sample 1, which is obviously wrong and means data is not recorded correctly.

From this, the question "How to properly store/record/train the model?" arises. A code example would be helpful. I will try to dig out the code I have used and get back to you.

As the saying goes for neural networks and alike, an algorithm is only as good as its data.

ahhhhhhh......OK, good catch, this makes sense. So essentially you are appending the new training example onto the end of the previously recorded data.

This example shows you how to record the timeseries data, note that at line 263 the latest training example (timeseries) is cleared after it has been added to the dataset:

https://github.com/nickgillian/ofxGrt/blob/master/example_dtw/src/ofApp.cpp

It sounds like in your code you are forgetting to clear the timeseries for each new example.

@BobbyCGD thank you for clarifying the issue.

@nickgillian Unfortunately, We have 2 issues here:
My goal is to implement DTW for time series classification of my gestures. Firstly, when i tried to upload the .csv file with varying columns i got an error "Inconsistent Columns", which actually makes sense but not for time series. For reference here is my sample data with varying columns data.txt

Secondly, when the first method didn't work out, i tried with fixed columns but thousands of rows with varying sequences (row wise). For example, Gesture 1 - 100 frames, Gesture 2 - 1500 frames, Gesture 3 - 500 frames and so on. Data here shortfixedcolumns.txt

Is there another way i can accomplish this task? Or a better algorithm to suit my data? Suggestions?

@nickgillian I am not entirely sure but i think there is error with .csv file loading. First, i made sure all my sequences are of equal size sortedshortfixedcolumns.txt. The DTWModel.grt generated by the program doesn't actually have all the .csv data and class labels. So it makes sense that it only classifies single class. Moreover, i tried to compare both files and found that the values in .grt file is random irrespective of class labels. DTWModel.txt. I guess there is some issue reading the .csv file properly.