joergsimon / SSL-ECG-Paper-Reimplementaton

Reimplementation of the paper Sarkar and Etemad 2020 "Self-Supervised ECG Representation Learning for Emotion Recognition"
25 stars 12 forks source link

How to use the weights #1

Open llsantos opened 3 years ago

llsantos commented 3 years ago

Fisrt, i would like to congratulate you on your implementation and i would like to know how to use the weights to use in a file containing the ecg.

Regards,

joergsimon commented 2 years ago

Sorry the super late reply, I am quite busy lately. First things first: The Model is not yet on the accuracy of the original paper implementation. The data extractors work with the original tensor flow implementation, so maybe that is also a way to get a model. I want to try to bring this version do the same accuracy but I am not yet sure when I have time.

However, I am also not sure if I understood your question. There are weights of the CNN model used for the pertaining. There weights are saved and you can load them with the provided model definition. If you want to transform your ECG dataset into a Dataset with features, you will load the model and the presaved weights and then apply the CNN on chops of 10s of the dataset, and save the outputs. Is that what you asked for?

llsantos commented 2 years ago

Thank you for answering, I want to make a prediction on an ECG sample, so I run "run_example.py" with wesad dataset, but I get this error: image

It's Like a window-200.data.npy file is missing

joergsimon commented 2 years ago

Ah, ok: So this error means that the dataset is not processed. To work with the repository you unfortunately still have to first get the Dataset by the original authors, because of law regulations. You then need to point the bath in constants to the dataset, and then the dataset is created. In case you have your own ECG data, that should also work, but you need to write a custom DataLoader.

LianFilipe commented 2 years ago

Hello @joergsimon , we work together with @llsantos and we have had more errors to load your code. I would like to know where the “tuned” folder is because we couldn't find it. To solve it, we used a .pt file from the" model_embedding" folder as“task_head_0.pt”. Also, we have done the adaptations mentioned before, but we had the same problem:

We are using the WESAD dataset, loading it in the Constants file:

joergsimon commented 2 years ago

so, I think the problem here is the following: When you have the original Data from WESAD f.e. you do not get it in a form suitable for pytorch. The data_base_path constant if for pointing the Dataset to the original data so it can create a dataset with is then usable with pytorch. This data is then saved into the cache_base_path. Since these are basepaths, it is assumed that the whole thing is structured as following: data_base_path / 'dataset1' data_base_path / 'dataset2' and so on, and then out of that the cache folders are created.

Now, what I do when creating the cache is, I create one pickled file for each index in the database, so on file for each ECG window, and one file for each label. This are files named something like window-N.data.npy. According to the error message this file is not present. Most likely this is the case because the cache is actually not created.

To have the cache created you have to have the original data you got from the authors in the data_base_path. For WESAD it could also be that I needed some additional octave script for conversion, I have to take a look. (In that case I can of course publish that script. Again, only the data I am legally not allowed to...).

LianFilipe commented 2 years ago

Alright, I would appreciate it if you could publish the additional conversion file.

Yas-bonfim commented 2 years ago

I have the same doubt mentioned by @Lipezin071. Could you publish the file, please?

joergsimon commented 2 years ago

I have a deadline until this weekend and can not focus on anything else till then. After that for sure (notify my please in case I forgot).

llsantos commented 2 years ago

Thanks @joergsimon! We are predicting the emotions now.

dousocool commented 2 years ago

I have a deadline until this weekend and can not focus on anything else till then. After that for sure (notify my please in case I forgot).

Hello, I am running your project, but the following problems occur. I only use wesad datasets, and I have commented out other datasets. Can you look at this error if you have time? I would appreciate it and look forward to your reply. 21M4JON YL))HN1B`95RI V Y7(SZB)R}CPRTS(XX}W)$DJ Z%YI6QB54B2~ J@LP 91 97

joergsimon commented 2 years ago

Hm, so I did not check out the implementation for a while, but I have a similar framework also in private use atm.; There I usually get this error when the following happens: Somehow on one of the attempts in creating the cached dataset a metadata file is created, but not the rest of the files. On the next start the system things the dataset is there because it just checks files. But then since the train_loader has no entries you get this division by zero. A first thing to try is to see if the /cache/wesad folder is really empty, and if not clean all (also hidden) files and try again. If that did not solve the problem I would have to see again.