Skip to content

Commit

Permalink
Merge pull request #23 from humphrem/1.0.0-updates
Browse files Browse the repository at this point in the history
Updates for downloading sample videos for 1.0.0
  • Loading branch information
humphrem authored Oct 31, 2023
2 parents 2a6aaf4 + db562e7 commit 0649edb
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 42 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ 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
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`:
Expand Down
6 changes: 3 additions & 3 deletions pixi.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion scripts/aquatic-demo.sh
Original file line number Diff line number Diff line change
@@ -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
36 changes: 0 additions & 36 deletions scripts/download-models.py

This file was deleted.

60 changes: 60 additions & 0 deletions scripts/download.py
Original file line number Diff line number Diff line change
@@ -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")
2 changes: 1 addition & 1 deletion scripts/terrestrial-demo.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0649edb

Please sign in to comment.