diff --git a/recipes/README.md b/recipes/README.md index 9457b7cfecd08308956c58f76601b8bc24258eac..b0eb228b5c1f8d3a8d0a33d374e76799455b7c05 100644 --- a/recipes/README.md +++ b/recipes/README.md @@ -4,24 +4,24 @@ Docker images can be used with the `docker` command. To make their usage easier, standalone scripts are available in the *scripts* directory. They can be used with no installation step other than setting up Docker. -Windows users should use the [larvatagger.ps1 script](#the-larvataggerps1-script), while macOS and Linux users should use the [larvatagger.sh script](#the-larvataggersh-script) instead. +Windows users should use the [larvatagger.bat script](#the-larvataggerbat-script), while macOS and Linux users should use the [larvatagger.sh script](#the-larvataggersh-script) instead. The first two sections describe how to use these scripts. The last section is dedicated to Singularity/Apptainer. -## The *larvatagger.ps1* script +## The *larvatagger.bat* script ### Getting the script -The *larvatagger.ps1* script is available in the *scripts* directory of the project. +The *larvatagger.bat* script is available in the *scripts* directory of the project. -If you do not have a copy of the project, you can simply [download the script](https://gitlab.pasteur.fr/nyx/larvatagger.jl/-/raw/main/scripts/larvatagger.ps1?inline=false). +If you do not have a copy of the project, you can simply [download the script](https://gitlab.pasteur.fr/nyx/larvatagger.jl/-/raw/main/scripts/larvatagger.bat?inline=false) and save it in your `C:\Users\<user>` directory. Note that Docker still has to be installed. -In PowerShell, to check the script works properly, change directory to where the *larvatagger.ps1* script is located and try: +In the command prompt (`cmd`), to check the script works properly, try: ``` -PowerShell.exe -ExecutionPolicy ByPass -File larvatagger.ps1 --version +larvatagger.bat --version ``` The first time the script runs, Docker downloads the latest image. @@ -30,19 +30,41 @@ The first time the script runs, Docker downloads the latest image. To open a track data file, try: ``` -PowerShell.exe -ExecutionPolicy ByPass -File larvatagger.ps1 open Z:\path\to\datafile +larvatagger.bat open Z:\path\to\datafile ``` This turns the commandline into a Julia interpreter to serve the app as a webserver. As instructed, open `localhost:9284` in your webbrowser to access the app. -Unlike instructed, you can stop the server in the commandline pressing Ctrl+C instead of Ctrl+D. +You can stop the server in the commandline pressing Ctrl+C. The server can also be exited typing `exit()` and pressing Enter. +The `--browser` argument mentioned elsewhere does not work with the *larvatagger.bat* script yet. + A default tagger will be available in the app. +### Automatic tagging + +To apply a tagger (e.g. `20230311`) to a track data file, type: +``` +larvatagger.bat predict Z:\path\to\datafile 20230311 +``` +This will create a *predicted.label* in the same directory as the data file. If the file already exists, it is overwritten. + +To apply a custom tagger, named e.g. *mytagger* and stored in the `C:\Users\<user>\models\mytagger` directory, type instead: +``` +larvatagger.bat predict Z:\path\to\datafile models\mytagger +``` +Here, `models\mytagger` is the relative path of the directory of the tagger. +This path has to include at least one `\` character so that it is identified as an external tagger. +Otherwise, LarvaTagger.jl would look up for the tagger inside the Docker container, and fail to find it. + ### More to come... +The `train`, `merge` and `import` commands work similarly to the *larvatagger.sh* script. See the below section to know more about these commands. + +Not all arguments and options are available, though. See also `larvatagger.bat --help`. + ## The *larvatagger.sh* script diff --git a/scripts/larvatagger.bat b/scripts/larvatagger.bat new file mode 100644 index 0000000000000000000000000000000000000000..553c2139bdc734b9b61ec534bda0ed9be37caf81 --- /dev/null +++ b/scripts/larvatagger.bat @@ -0,0 +1 @@ +PowerShell.exe -ExecutionPolicy ByPass -File larvatagger.ps1 $* diff --git a/scripts/larvatagger.ps1 b/scripts/larvatagger.ps1 index 54275affaa32f3a14163492efb1aa39b74c067bf..79b8c8638d91d742c6601959e533cfbd631fca2e 100644 --- a/scripts/larvatagger.ps1 +++ b/scripts/larvatagger.ps1 @@ -36,7 +36,9 @@ function Call1 { $args = $args -split ' ' $cmd = $args[0] $path = Convert-Path $args[1] - $extraargs = $args[2..($args.count - 1)] + if ($args.count -gt 2) { + $extraargs = $args[2..($args.count - 1)] + } if ($cmd -eq 'open') { $runargs = '-p', '9284:9284', '-i' } @@ -99,7 +101,9 @@ Switch ($args[0]) New-Item -Path $modelsdir -ItemType 'directory' } $taggername = Split-Path -Leaf $taggerpath - $extraargs = $args[3..($args.count - 1)] + if ($args.count -gt 3) { + $extraargs = $args[3..($args.count - 1)] + } Write-Host "docker run --mount `"type=bind,src=$modelsdir,dst=/app/$TAGGING_BACKEND/models`" -v ${parentdir}:/data $LARVATAGGER_IMAGE train /app/$TAGGING_BACKEND /data/$dirname $taggername $extraargs" docker run --mount "type=bind,src=$modelsdir,dst=/app/$TAGGING_BACKEND/models" -v ${parentdir}:/data $LARVATAGGER_IMAGE train /app/$TAGGING_BACKEND /data/$dirname $taggername $extraargs } @@ -116,7 +120,9 @@ Switch ($args[0]) } $parentdir = Split-Path -Parent $path $filename = Split-Path -Leaf $path - $extraargs = $args[3..($args.count - 1)] + if ($args.count -gt 3) { + $extraargs = $args[3..($args.count - 1)] + } Write-Host "docker run $runargs -v ${parentdir}:/data $LARVATAGGER_IMAGE predict /app/$TAGGING_BACKEND $taggername /data/$filename $extraargs" docker run $runargs -v ${parentdir}:/data $LARVATAGGER_IMAGE predict /app/$TAGGING_BACKEND $taggername /data/$filename $extraargs }