diff --git a/README.md b/README.md index 60747b1..a8ee1b1 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ The easiest way to use it is with the [pixi](https://prefix.dev/docs/pixi/overvi 1. Download the **Source code** (`zip` or `tar.gz`) from the [Releases](https://github.com/humphrem/action/releases) page, or use Git to clone this repo using `git clone https://github.com/humphrem/action.git` 2. [Install pixi](https://prefix.dev/docs/pixi/overview#installation) using the instructions for your operating system. NOTE: on Windows, if using the [`iwr` command](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.3), make sure you are using [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/overview?view=powershell-7.3) vs. cmd.exe/Terminal, or use the [MSI Windows Installer](https://prefix.dev/docs/pixi/overview#windows-installer). 3. Start a terminal and navigate to the root of the Action project folder you just downloaded or cloned, `cd action` -4. Enter the command `pixi run setup` to install dependencies and to download the AI models (NOTE: these are large, ~778M, and will take some time to download) +4. Enter the command `pixi run setup` to install dependencies and to download the AI models and sample videos (NOTE: the models are large, ~778M, and will take some time to download). ```sh git clone https://github.com/humphrem/action.git @@ -27,6 +27,11 @@ cd action pixi run setup ``` +When setup is complete, you will have two additional directories: + +1. `video` - sample video files you can use to test +2. `models` - the ONNX models needed to do the detections + ### Using the Pixi Shell Environment Each time you want to use Action, open a terminal, navigate to the Action folder, and start a shell with `pixi`: diff --git a/pixi.toml b/pixi.toml index 9bc8109..424bc89 100644 --- a/pixi.toml +++ b/pixi.toml @@ -1,6 +1,6 @@ [project] name = "action" -version = "1.0.0-beta" +version = "1.0.0" description = "Automated Camera Trapping Identification and Organization Network (ACTION)" repository = "https://github.com/humphrem/action" readme = "README.md" @@ -11,9 +11,9 @@ channels = ["conda-forge"] platforms = ["win-64", "linux-64", "osx-64", "osx-arm64"] [tasks] -download-models = "python scripts/download-models.py" +download = "python scripts/download.py" install-requirements = "pip install -r requirements.txt" -setup = {depends_on=["install-requirements", "download-models"]} +setup = {depends_on=["install-requirements", "download"]} lint = "ruff check ." [target.osx-arm64.tasks] diff --git a/scripts/aquatic-demo.sh b/scripts/aquatic-demo.sh index 5dbe5e0..6c0499f 100755 --- a/scripts/aquatic-demo.sh +++ b/scripts/aquatic-demo.sh @@ -1,3 +1,3 @@ #!/bin/bash -python3 action.py ./video/aquatic-demo.mov -c 0.45 -m 3.0 -s -b 1.0 -d -e aquatic +python3 action.py ./video/aquatic_demo_1.mov -c 0.45 -m 3.0 -s -b 1.0 -d -e aquatic diff --git a/scripts/download-models.py b/scripts/download-models.py deleted file mode 100644 index 9327818..0000000 --- a/scripts/download-models.py +++ /dev/null @@ -1,36 +0,0 @@ -import os -import requests - -# Get the package version from the environment variable -package_version = os.getenv("PIXI_PACKAGE_VERSION") - -# URLs of the ONNX model files -urls = [ - f"https://github.com/humphrem/action/releases/download/v{package_version}/md_v5a_1_3_640_640_static.onnx", - f"https://github.com/humphrem/action/releases/download/v{package_version}/yolov4_1_3_608_608_static.onnx", -] - -# Create the models directory if it does not exist -if not os.path.exists("models"): - os.makedirs("models") - print("Created 'models' directory") - -# Download each file -for url in urls: - # Get the file name by splitting the URL and taking the last part - file_name = url.split("/")[-1] - - # Check if the file already exists - if not os.path.exists(os.path.join("models", file_name)): - print(f"Downloading {file_name} (this will take some time...)") - - # Send a HTTP request to the URL of the file - response = requests.get(url) - - # Write the content of the response to a file in the models directory - with open(os.path.join("models", file_name), "wb") as file: - file.write(response.content) - - print(f"Downloaded {file_name} successfully.") - else: - print(f"{file_name} already exists, skipping download.") diff --git a/scripts/download.py b/scripts/download.py new file mode 100644 index 0000000..6fd85f3 --- /dev/null +++ b/scripts/download.py @@ -0,0 +1,60 @@ +import os +import requests + +# Get the package version from the environment variable +package_version = os.getenv("PIXI_PACKAGE_VERSION") + +# URLs of the ONNX model files +model_urls = [ + f"https://github.com/humphrem/action/releases/download/v{package_version}/md_v5a_1_3_640_640_static.onnx", + f"https://github.com/humphrem/action/releases/download/v{package_version}/yolov4_1_3_608_608_static.onnx", +] + +# URLs of the sample video files +video_urls = [ + f"https://github.com/humphrem/action/releases/download/v{package_version}/aquatic_demo_1.mov", + f"https://github.com/humphrem/action/releases/download/v{package_version}/aquatic_demo_2.mov", + f"https://github.com/humphrem/action/releases/download/v{package_version}/terrestrial_demo_1.mov", + f"https://github.com/humphrem/action/releases/download/v{package_version}/terrestrial_demo_2.mov", +] + + +# Function to download files +def download_files(urls, directory): + # Download each file + for url in urls: + # Get the file name by splitting the URL and taking the last part + file_name = url.split("/")[-1] + + # Check if the file already exists + if not os.path.exists(os.path.join(directory, file_name)): + print(f"Downloading {file_name} (this will take some time...)") + + # Send a HTTP request to the URL of the file + response = requests.get(url) + + # Write the content of the response to a file in the directory + with open(os.path.join(directory, file_name), "wb") as file: + file.write(response.content) + + print(f"Downloaded {file_name} successfully.") + else: + print(f"{file_name} already exists, skipping download.") + + +# Create the models directory if it does not exist +if not os.path.exists("models"): + os.makedirs("models") + print("Created 'models' directory") + +# Download model files +download_files(model_urls, "models") + + +# Create the video directory if it does not exist +if not os.path.exists("video"): + os.makedirs("video") + print("Created 'video' directory") + +# Download video files +download_files(video_urls, "video") diff --git a/scripts/terrestrial-demo.sh b/scripts/terrestrial-demo.sh index e9ffb23..f296e00 100755 --- a/scripts/terrestrial-demo.sh +++ b/scripts/terrestrial-demo.sh @@ -1,3 +1,3 @@ #!/bin/bash -python3 action.py ./video/terrestrial-demo.mov -c 0.45 -m 3.0 -s -i -b 1.0 -d -e terrestrial +python3 action.py ./video/terrestrial_demo_1.mov -c 0.45 -m 3.0 -s -i -b 1.0 -d -e terrestrial