DOI: 10.5061/dryad.v6wwpzh3g
title: Data from: A hands-on guide to use network video recorders, internet protocol cameras, and deep learning models for dynamic monitoring of trout and salmon in small streams

description: This study outlines a method for using surveillance cameras and an
 algorithm that calls a deep learning model to generate video segments
 featuring salmon and trout in small streams. This automated process
 greatly reduces the need for human intervention in video surveillance.
 Further, a comprehensive guide is provided on setting up and configuring
 surveillance equipment, along with instructions on training a deep
 learning model tailored to specific requirements. Access to video data and
 knowledge about deep learning models makes monitoring of trout and salmon
 dynamic and hands-on, as the collected data can be used to train and
 further improve deep learning models. Hopefully, this setup will encourage
 fisheries managers to conduct more monitoring as the equipment is
 relatively cheap compared to customized solutions for fish monitoring. To
 make effective use of the data, natural markings of the camera captured
 fish can be used for individual identification. While the automated
 process greatly reduces the need for human intervention in video
 surveillance and speeds up the initial sorting and detection of fish, the
 manual identification of individual fish based on natural markings still
 requires human effort and involvement. Individual encounter data holds
 many potential applications; such as capture-recapture and relative
 abundance models, and for evaluating fish passages in streams with hydro
 power by spatial recaptures, i.e., the same individual identified at
 different locations. There is much to gain by using this technique as
 camera captures are the better option for the fish’s welfare and less time
 consuming compared to physical captures and tagging.
description: Please refer to the article and the README file with the
 deposited data.
description: # A hands-on guide to use network video recorders, internet protocol
 cameras, and deep learning models for dynamic monitoring of trout and
 salmon in small streams
 [https://doi.org/10.5061/dryad.v6wwpzh3g](https://doi.org/10.5061/dryad.v6wwpzh3g) Konrad Karlsson Department of Aquatic Resources, Institute of Freshwater Research, Swedish University of Agricultural Sciences, \ Stångholmsvägen 2, 178 93 Drottningholm, Sweden \## Below is a brief description of the .py and .R scripts, what the scripts do and the folder(s) they relate to. You will have to set the directory in the scripts in order to run them. There is a word file provided to make it easier to get Python, TensorFlow and ffmpeg installed on Windows 10: \ "Install and run TensorFlow and ffmpeg on Windows 10.docx". **Important note:** The Python scripts are an essential part of the study. The two R scripts, "train model in R.R" and "split video files in R.R", are similar to what is included in the Python scripts and may be a bit redundant. The remaining two R scripts, "predict with model and view photos of set probability in R.R" and "table 1 match probabilities July 22 to 27 in R.R," are meant to scrutinize and visualize model results. \#################### \### **Python scripts** \#################### "train model in Python.py":\ Reads the training data from the folder "fish train images Skeboån Mörrumsån Älvkarleby," trains one model with the best set of hyper-parameters already evaluated in the R version of this script, and saves the model as "fish_mod_python." "split video files predict from model and write videos in Python.py":\ This script reads the video files in the folder "camera2 26 July," splits them into one image per 20 seconds, and saves the images in the folder "images goes here Python." This process may take a while (approximately 2 hours on my PC), but it is significantly faster than the R option. The images in the folder "images goes here Python" are used for prediction by loading the deep learning model "fish_mod_python." The structure of the videos in "camera2 26 July" is probed to get the corresponding video frame of the predicted images. Video files are then written to the folder "video files goes here Python." \#################### \### **R scripts** \#################### "train model in R.R":\ Reads the training data from the folder "fish train images Skeboån Mörrumsån Älvkarleby," trains 8 models with different hyper-parameters, and saves the best one based on accuracy as "fish_mod_R." "split video files in R.R":\ Reads the video files in the folder "camera2 26 July," splits them into one image per 20 seconds, and saves the images in the folder "images goes here R" - this code is very slow. "predict with model and view photos of set probability in R.R":\ Here, the images created by the above script are already provided since the code is slow. They are read from the "images to predict" folder, which contains images from 22-27 July 2023. The deep learning model is loaded from "fish_mod_R" and used to predict the images from the 26th of July. The images with a specified probability can be viewed using the R browser function. "table 1 match probabilities July 22 to 27 in R.R":\ Produces table 1 presented in the manuscript. It reads the probability (already estimated by the script above) for each image for the dates 22-27 July and creates a frequency table of probabilities per date. It takes data from the "predictions July 22 to 27" folder. \##################### \## **Other data** \##################### The folder "video examples camera2 26 July" contains the expected result of the "split video files predict from model and write videos in Python.py" script