vilari-mickopf / mmwave-gesture-recognition

Basic Gesture Recognition Using mmWave Sensor - TI AWR1642
MIT License
104 stars 21 forks source link

Off-line Testing #9

Closed hua812586 closed 1 year ago

hua812586 commented 1 year ago

Hello @vilari-mickopf. Thanks for your great repository ‘mmwave-gesture-recognition’. Howover,I have a question that I would like to consult with you?

Now I can use the 1642 board to actually test gestures and accurately recognize them. But now I want to use the CSV file in the data for offline testing (that is, write a separate predicted file(.py), pass the CSV data in during runtime, and directly print out the results), but I don't know how to use the existing code to achieve it? Can you help me take a look?

Thanks for your help in advance. I wish to hear from you as soon as possible.

vilari-mickopf commented 1 year ago

Haven't tested it, but something like this should work:

import pandas as pd

from mmwave.model import LstmModel

def load_sample(path):
    df = pd.read_csv(path)
    num_of_frames = df.iloc[-1]['frame'] + 1
    sample = [[] for _ in range(num_of_frames)]

    for _, row in df.iterrows():
        if row['x'] == 'None':
            obj = 5*[0.]
        else:
            obj = [
                float(row['x'])/65535.,
                float(row['y'])/65535.,
                float(row['range_idx'])/65535.,
                float(row['peak_value'])/65535.,
                float(row['doppler_idx'])/65535.
            ]
        sample[row['frame']].append(obj)
    return sample

model = LstmModel()
model.load()  # loads model from `mmwave/.lstm_model`
model.predict([load_sample(<path>)])
hua812586 commented 1 year ago

Wow, thank you very much for your help. It can be used.