irllabs / ml-lib

A machine learning library for Max and Pure Data
Other
274 stars 40 forks source link

DTW crashes in Max 8 #177

Closed Knallberto closed 3 years ago

Knallberto commented 3 years ago

Hi, I tried usind the dynamic time warping example you provide, but when I want to start 'mapping' Max crashes. I don't know why this happens, I get no error message. I am working with Max 8 and "ml.dtw 1.1.2: Dynamic Time Warping based on the GRT library version 0.2.5 revision: 2-Jan-2017".

NiccoloGranieri commented 3 years ago

Hi @Knallberto, I just tested [ml.dtw] on Max 8 both from scratch and using the provided example and I am unable to reproduce your issue. Could you provide us with a bit more info on your setup? Are you using the ml.lib version found on the Max Package Manager? Are you running macOS or Windows? If macOS what version exactly? What is the exact procedure you need to follow to make the app crash? Thanks in advance for your time!

Knallberto commented 3 years ago

Hi, thanks for the reply and thanks for your time! I am running Windows 10 Home with a i5-4440 CPU @ 3.1GHz, 16GB Ram. I installed ml.lib with the max packages manager (ml.lib by IRL Labs 1.1.2) in Max 8 (64-bit). First I tried with Data from a MMA8452 Sensor with Arduino and serial communication. I pressed the clear button, chose train in the dropdown menu, selecteded the first button, clicked listen, made a gesture with the sensor (circle) and then stopped the listen button. I repeated the same procedure for two more slots, then clicked train and selected map in the drop-down menu. I clicked on listen and after a few seconds max crashed. I tried this a few times and everytime I got in the map mode and started listening it crashed. Next, I tried exactly the same procedure with data from the accellerometer in my iphone using GyrOSC and udpreceive (like in the example). This also crahes after a few seconds of incoming Data in the mapping mode. I did not change any of the default settings.

NiccoloGranieri commented 3 years ago

Hi @Knallberto, I just tested this on a Windows 10 machine and unfortunately (or luckily?) I can't reproduce the crash. Before we go down the log-rabbit hole could you please do me a favour and uninstall ml.lib, restart your laptop, and re-install a fresh copy? If the good old "have you tried turning it off and on again" doesn't work, I'll probably ask you to send me some logs.

Knallberto commented 3 years ago

I installes a fresh copy and restarted my computer, still the same problem. When I stop the 'listen' in mapping mode fast enough, before max crashes, I get the message: "error: ml.dtw: unable to map input". How do I create logs?

NiccoloGranieri commented 3 years ago

Ok, so make it crash, and find the crash log here:

C:\Users\yourusername\AppData\Roaming\Cycling '74\Logs

Send me the latest one and I'll see what I can do.

Knallberto commented 3 years ago

I tried to make it crash to create a logfile, but no log file is created. Strangely, there is a logfile from yester in the folder that probably includes the same information (?). So the crash goes like this: first the window 'freezes', when I try to do something it gets greyed out and a message from windows appears "program is not responding. When I close the program and restart I get the "Looks like Max previously crashed. Would you like to recover your work?" message. But no logfile. I attatched the logfile from yesterday, maybe there is some useful information. Max-2021-02-15_22-52-43-667771f.zip

update: I recreated the example patch in Pure Data and the mapping seems to work fine here. update2: my pure Data version is also hanging after a while, but it doesn't freeze like max

NiccoloGranieri commented 3 years ago

So after having a chat with the lead dev on this project it seems like Max is hanging not crashing. Could you please tell us:

Knallberto commented 3 years ago

With ml.ann I am not sure if I am doing it right. I gave examples for different presets (so first I selected a preset, then I hit the toggle, then turned off the toggle and selected another preset and so forth) for the soundz patcher, is that correct? I receive a message "error: invalid input length, expected 8, got 3" when I select map. I also tried the "4-Pose_Recognition-SVM.maxpat" - here the class output seems to be totally wrong, but I do not get an error message and there is no crash or 'hanging'.

CPU load is around 30%

cpu_load_max
NiccoloGranieri commented 3 years ago

Yeah I just saw that the [ml.ann] example is missing a few steps. If you want to try it, I'll attach an updated version but I don't think you're going to have issues with it. 6-Multi-Dimenional_Mapping-ANN.maxpat.zip

Knallberto commented 3 years ago

Thanks for the patch, this is working perfectly

Knallberto commented 3 years ago

I tried to use the DTW patch on another computer and there I get the same problem.

NiccoloGranieri commented 3 years ago

That's interesting @Knallberto. Before we dive deep into DTW, would you mind saving the ml.dtw data and sending it over together with a few seconds worth of data streaming from your phone? You could record the data into a test file using the [coll] object. To save the ML file instead, just pass a (write) message to the ml object specifying the path.

Knallberto commented 3 years ago

Thanks for the reply, I tried to record the data, but I do not know how to do it. When I specify the path with the "write" message, how exactly does it have to look? when I just type something like c:/folder/filename I get a "unable to write model to path" message. And I also do not know how the coll object works, do I have to prepend a number (1,2,3 ...) to ever list I want to record?

NiccoloGranieri commented 3 years ago

Here you go @Knallberto, use this to generate a ".data" file and a ".txt" file, and send those back. dataRecording.maxpat.zip

Knallberto commented 3 years ago

Thanks for the patch, here is the data: DTW_data.zip

NiccoloGranieri commented 3 years ago

Hi @Knallberto, having a look at the data you sent over nothing seems to be wrong. However, I managed to make Max hang by mapping continuous data for a bunch of seconds. So my question is: when you map data, are you delimitating the "gestures" by turning on and off the listening toggle, or are you turning the listening on expecting DTW to recognise and segment the individual gestures previously trained?

Knallberto commented 3 years ago

Hi, I see, I am "turning the listening on expecting DTW to recognise and segment the individual gestures previously trained" - is this not possible?

NiccoloGranieri commented 3 years ago

No, unfortunately not. However, you could implement something to make it work that way in your patch. For example, let's say you're trying to recognise shapes drawn on a drawing tablet. You could use the act of touching the tablet with the pen as "turn listening on", and turn it off when the pen is lifted. This could be anything, it really depends on the devices/hardware you're using.

Knallberto commented 3 years ago

Okay, sorry I did not know this. Thank you for your time! I was thinking of using a IMU Sensor with x/y/z information to recognise gestures while moving it.