-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working on scripts for launching container
- Loading branch information
Showing
14 changed files
with
235 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
__pycache__ | ||
|
||
tests/output/* | ||
|
||
!test/output/.gitkeep | ||
|
||
tests/input/* | ||
!test/input/.gitkeep | ||
|
||
local_scripts/* | ||
|
||
*.ipynb_checkpoints/ | ||
*.ipynb_checkpoints/* | ||
|
||
.vscode/launch.local.json | ||
.vscode/launch.local.json | ||
|
||
temp | ||
temp/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Argument Parsing | ||
$source = $args[0] | ||
$output = $args[1] | ||
$recognizer = $args[2] | ||
$image = $args[3] | ||
if ($null -eq $image) { $image = "qutecoacoustics/perchrunner:latest" } | ||
|
||
# Required Parameter Validation | ||
if ([string]::IsNullOrWhiteSpace($source) -or [string]::IsNullOrWhiteSpace($output) -or [string]::IsNullOrWhiteSpace($recognizer)) { | ||
Write-Host "Error: Missing required parameters (--source, --output, --recognizer)" | ||
exit 1 | ||
} | ||
|
||
# Source Path Checks | ||
if (-not (Test-Path -Path $source)) { | ||
Write-Host "Error: Source path does not exist: $source" | ||
exit 1 | ||
} | ||
elseif ((Test-Path -Path $source -PathType Container) -and ((Get-ChildItem -Path $source).Count -eq 0)) { | ||
Write-Host "Error: Source directory is empty: $source" | ||
exit 1 | ||
} | ||
|
||
# Output Folder Check | ||
if (-not (Test-Path -Path $output -PathType Container)) { | ||
Write-Host "Error: Output folder does not exist: $output" | ||
exit 1 | ||
} | ||
|
||
# Recognizer Config Mapping | ||
$recognizer_configs = @{ | ||
"pw" = "pw.classify.yml" | ||
"cgw" = "cgw.classify.yml" | ||
} | ||
|
||
$config_file = $recognizer_configs[$recognizer] | ||
if ($null -eq $config_file) { | ||
Write-Host "Recognizer $recognizer not supported" | ||
exit 1 | ||
} | ||
else { | ||
Write-Host "Using config file: $config_file" | ||
} | ||
|
||
# Paths inside the container, to be mounted | ||
$embeddings_container = "/mnt/embeddings" | ||
$output_container = "/mnt/output" | ||
$output_dir = Join-Path $output_container "search_results" | ||
|
||
$command = "python /app/src/app.py classify --source $embeddings_container --output $output_container --config_file $config_file" | ||
|
||
# Convert to absolute paths | ||
$absolute_source = (Resolve-Path -Path $source).Path | ||
$absolute_output = (Resolve-Path -Path $output).Path | ||
|
||
Write-Host "launching container with command: $command" | ||
|
||
# Launch Docker container | ||
docker run --user appuser:appuser --rm ` | ||
-v "$absolute_source":$embeddings_container ` | ||
-v "$absolute_output":$output_container $image $command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Argument Parsing | ||
$source = $args[0] | ||
$output = $args[1] | ||
$image = $args[2] | ||
if ($null -eq $image) { $image = "qutecoacoustics/perchrunner:latest" } | ||
|
||
# Required Parameter Validation | ||
if ([string]::IsNullOrWhiteSpace($source) -or [string]::IsNullOrWhiteSpace($output)) { | ||
Write-Host "Error: Missing required parameters (source, output)" | ||
exit 1 | ||
} | ||
|
||
Write-Host (Get-Location) | ||
Write-Host $source | ||
|
||
# Source Path Checks | ||
if (-not (Test-Path -Path $source -PathType Leaf)) { | ||
Write-Host "Error: Source audio folder does not exist: $source" | ||
exit 1 | ||
} | ||
|
||
# Paths to things inside the container, to be mounted | ||
$source_container = "/mnt/input" | ||
$output_container = "/mnt/output" | ||
|
||
$source_folder_host = Split-Path -Path $source -Parent | ||
$source_basename = Split-Path -Path $source -Leaf | ||
|
||
$command = "python /app/src/app.py generate --source $source_container/$source_basename --output $output_container" | ||
|
||
Write-Host "launching container with command: $command" | ||
|
||
# Convert to absolute paths | ||
$absolute_source = (Resolve-Path -Path $source_folder_host).Path | ||
$absolute_output = (Resolve-Path -Path $output).Path | ||
|
||
# Launch Docker container | ||
& docker run --user appuser:appuser --rm ` | ||
-v "$absolute_source":$source_container ` | ||
-v "$absolute_output":$output_container $image $command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Step 1. Install Docker | ||
|
||
Go to https://www.docker.com/get-started/ and install Docker for your computer if you don't already have it installed. The recognizer is provided as a docker container, and you need this software installed to be able to run it. | ||
|
||
# Step 2. Embed audio | ||
|
||
1. Open a terminal window | ||
2. Change directory to this scripts directory | ||
3. Run the following command: | ||
- windows: `pwsh embed.ps1 [path_to_audio_folder] [path_to_embeddings_output_folder]` | ||
- linux or intel mac: `./embed.sh [path_to_audio_folder] [path_to_embeddings_output_folder]` | ||
|
||
|
||
Notes | ||
- In the command above, replace the placeholders with your real audio and output folder. The output folder is where the embeddings files will get saved. | ||
- This will take quite a long time to run. It's possible that it's too slow to be practical, depending on how much audio you have | ||
|
||
# Step 3. Classify embeddings | ||
|
||
1. Open a terminal window | ||
2. Change directory to this scripts directory | ||
3. Run the following command: | ||
- windows: `pwsh classify.ps1 [path_to_audio_folder] [path_to_embeddings_folder] 'pw'` | ||
- linux or intel mac: `./classify.sh [path_to_audio_folder] [path_to_classifications_output_folder] 'pw'` | ||
|
||
|
||
Notes | ||
- In the command above, replace the placeholders with your real embeddings folder (which you specified in step 1) and output folder. The output folder is where the csv files of classifications will be saved. These files score each 5 second segment. Any score above zero is a positive classification. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.