Using the Model

Predicting the ages of a set of menhaden scale images

Running the Menhaden Ageing Model is straightforward and only requires one command. You will, however, need three things on hand:

  1. The directory containing the scale images to process
  2. The directory where you want the model output file to be written
  3. The directory containing the trained model weights (i.e., the best_model.pth file). If you simply cloned the repo and have not moved anything around, this file will be alongside the model script in the scripts subdirectory in the cloned repository.

First we need to activate the virtual environment we previously configured. In a terminal window, type:

conda activate scaleageing
Tip

If you named your virtual environment something other than “scaleageing”, invoke that name instead.

Navigate into the directory containing the Scale_Aging_Inference_Script_Image_Only.py script. If you simply cloned the repo and have not moved anything around, this will in the scripts subdirectory in the cloned repository.

Run the model as described in the usage instructions:

python Scale_Aging_Inference_Script_Image_Only.py <img_dir> <csv_dir> <model_dir>

where <img_dir> is the full path to the directory containing the scale images to process (#1 above), <csv_dir> is the full path to desired directory to which the CSV output will be written (#2 above), and <model_dir> is the full path to the directory containing the best_model.pth model weights (#3 above).

An Example

Directories are handled slightly differently in DOS (Windows Command Prompt, Powershell) than UNIX (Git Bash). For example, running on the Advanced Technology GPU machine might to process 2024 menhaden data might look like this:

Git Bash

python Scale_Aging_Inference_Script_Image_Only.py "G:/Shared drives/NMFS SEFSC FATES Advanced Technology/BIOLOGY_LIFE_HISTORY_DATA/Atlantic menhaden to be tested w active learning/subset" "G:/Shared drives/NMFS SEFSC FATES Advanced Technology/BIOLOGY_LIFE_HISTORY_DATA/Atlantic menhaden to be tested w active learning/model_age_predictions" "C:/Users/user.name/Documents/GitHubRepos/FATES-BLH-ScaleAgeing/scripts"

Command Prompt

python Scale_Aging_Inference_Script_Image_Only.py “G:\Shared drives\NMFS SEFSC FATES Advanced Technology\BIOLOGY_LIFE_HISTORY_DATA\Atlantic menhaden to be tested w active learning\subset” “C:\Shared drives\NMFS SEFSC FATES Advanced Technology\BIOLOGY_LIFE_HISTORY_DATA\Atlantic menhaden to be tested w active learning\model_age_predictions” “C:\Users\user.name\Documents\GitHubRepos\FATES-BLH-ScaleAgeing\scripts”