Skip to content
Snippets Groups Projects
Commit 0e0eb21d authored by Tomas Martinovic's avatar Tomas Martinovic
Browse files

update README.md and add image name into docker-compose.yml

parent b2f3d391
No related branches found
Tags
No related merge requests found
# Movement Classification # Movement Classification
This repository contains scripts to compute features and classify people based on their motion dynamics characteristics from the movement data collected by Palacký University, Olomouc (10.5281/zenodo.10984138).
The workflow is divided into two steps feature extraction and classification. This repository contains scripts to compute features and classify people based on their motion dynamics characteristics from the movement data collected by Palacký University, Olomouc [10.5281/zenodo.10984138](https://zenodo.org/records/10984138).
# Prerequisities The workflow is divided into two steps
For this project we use R and Python, Python is used only for the part of computing the features from raw data and it is not necessary for the classification from the features. 1. feature extraction,
2. movement activities classification.
## Step 1 Feature extraction There are multiple approaches to executing the scripts.
During our tests we had trouble to execute the feature extraction part on MacOS and Windows due to difficulties with installation of correct Python environment which would be executed by R `reticulate` package.
The classification part is completely written in R and should work fine on all systems.
It is possible to run both scripts on all major operation systems using docker image. For more information see [Docker execution](#docker-execution) section.
To run the scripts without using docker see [Native execution](#native-execution) section.
The last way of working with the script is using R IDE [RStudio](https://posit.co/products/open-source/rstudio/) and execute them from there, see this [link](https://rmarkdown.rstudio.com/lesson-1.html) for more information.
In case of RStudio usage, the prerequisites must be install the same way as for the [Native execution](#native-execution).
### Software Since the first part of features computation is taking up to 12 hours on common laptops, we provided results of this part at Zenodo, see [10.5281/zenodo.10996083](https://zenodo.org/records/10996083).
Thanks to this it is possible to focus on the second part of the execution workflow which should take 10 to 50 minutes depending on the system installation.
The execution time is affected by the architecture (amd64 vs arm) and whether R packages are compiled to use parallel libraries.
R version 4.3.3 (2024-02-29), Python version 3.8.10 (default, Nov 22 2023, 10:22:35), # Docker execution
libraries:
- if (!require('tidyverse')) install.packages('tidyverse'); library('tidyverse')
- if (!require('Chaos01')) install.packages('Chaos01'); library('Chaos01')
- if (!require('nonlinearTseries')) install.packages('nonlinearTseries'); library('nonlinearTseries')
- if (!require('reticulate')) install.packages('reticulate'); library('reticulate')
- reticulate::py_install("tsfresh")
### Data ## Download repository files
- The Data can be found at https://zenodo.org/records/10984138? To download repository files, You can use `git clone` command:
- Download it from the site.
- Change path in `get_features.Rmd` to the local folder, where the data was downloaded. ```shell
git clone https://code.it4i.cz/ADAS/movement-classification.git
```
or click on button "Code" in the top right part of the tab above the list of files and download all files as zip.
## Install docker desktop
- [MacOS](https://docs.docker.com/desktop/install/mac-install/)
- [Windows](https://docs.docker.com/desktop/install/windows-install/)
- [Linux](https://docs.docker.com/desktop/install/linux-install/)
## Running the scripts from docker
Among the repository files is pre-prepared `docker-compose.yml` file which contains configuration for execution of both steps.
## Step 1 Features computation (optional, takes a long time to compute)
In Your terminal navigate to the folder where the files from the repository are downloaded and execute the following command:
```shell
docker compose run movement-classification R --quiet -e "rmarkdown::render('get_features.Rmd')"
```
By default input dat are downloaded into a folder `data_zenodo` and output features are also placed into this folder.
## Step 2 Classification ## Step 2 Classification
### Software In case You have not run the first step, in this step features are downloaded from the Zenodo repository containing pre-computed features.
In Your terminal navigate to the folder where the files from the repository are downloaded and execute the following command:
```shell
docker compose run movement-classification R --quiet -e "rmarkdown::render('get_results.Rmd')"
```
RStudio is not required to run .... See section [How to run the scripts](#how-to-run-the-scripts) The results are HTML document placed into the folder `output`.
R version 4.3.3 (2024-02-29), Python, libraries ## Customization
### Data The docker compose configuration is prepared in such a way, that it will replace `get_features.Rmd` and `get_results.Rmd` in a docker image by the ones on the local filesystem.
That means, that in case You change something in these two files, it will also be changed for the computation.
In `get_features.Rmd` there are 3 parameters related to the recurrence plot definition on lines 23 - 25.
In `get_results.Rmd` there are a number of parameters from line 49 to line 97.
- The Data can be found at https://zenodo.org/records/10996083 # Native execution
- Download it from the site.
- Change path in `get_results.Rmd` to the local folder, where the data was downloaded. ## Download repository files
To download repository files, You can use `git clone` command:
```shell
git clone https://code.it4i.cz/ADAS/movement-classification.git
```
# How to prepare environment or click on button "Code" in the top right part of the tab above the list of files and download all files as zip.
For R (You can skip this step if You have done it already) ## Step 1 Feature extraction (optional, takes a long time to compute)
### Prerequisities
- R version 4.2.0 or greater
Install dependencies in R command line execute
```R ```R
install.packages("renv") install.packages("renv")
renv::restore() renv::restore()
``` ```
For Python requirements file Install python environment from R command line, note this is not needed if only the classification is done, see Step 2 Classification below:
```R
reticulate::install_python()
reticulate::virtualenv_create("hmch")
reticulate::virtualenv_install("hmch", c("-r", "requirements.txt"))
```
### Model execution
Now You can execute the script by calling
```bash ```bash
python -m venv .venv R -e "rmarkdown::render(get_features.Rmd)"
source .venv/bin/activate
python -m pip install -r requirements.txt
``` ```
# How to run the scripts ## Step 2 Classification
### Prerequisities
- R version 4.2.0 or greater
The whole workflow is divided into two files, where the first one `get_features.Rmd` includes the feature extraction part. The second `get_results.Rmd` includes feature reduction and SOM training. All used functions are included in the `functions` folder. Install dependencies in R command line execute
```R
install.packages("renv")
renv::restore()
```
### Model execution
```bash ```bash
R -e "rmarkdown::render(get_features.Rmd) R -e "rmarkdown::render(get_results.Rmd)"
``` ```
At the same time this file reproduce figures from an article which is now under review and later we will link it when it is published. At the same time this file reproduce figures from an article which is now under review and later we will link it when it is published.
# Ideas for other settings options to explore ## Customization
...
scripts - model - line number in file or where to find it somehow chunk number something - features to change The docker compose configuration is prepared in such a way, that it will replace `get_features.Rmd` and `get_results.Rmd` in a docker image by the ones on the local filesystem.
\ No newline at end of file That means, that in case You change something in these two files, it will also be changed for the computation.
In `get_features.Rmd` there are 3 parameters related to the recurrence plot definition on lines 23 - 25.
In `get_results.Rmd` there are a number of parameters from line 49 to line 97.
services: services:
movement-classification: movement-classification:
image: nithador/movement-classification
build: build:
context: . context: .
container_name: movement-classification container_name: movement-classification
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment