diff --git a/.github/workflows/cmake-macos.yml b/.github/workflows/cmake-macos.yml index fccabf499fd9f9803590e8dbc667c58f3fc0d7f9..5efc97284d6f00c8ad86912dd45780f1716c5865 100644 --- a/.github/workflows/cmake-macos.yml +++ b/.github/workflows/cmake-macos.yml @@ -71,5 +71,5 @@ jobs: echo "::group::TestFunctions" conda install -y unzip cd $GITHUB_WORKSPACE/Application/Tests - ./run_macos.bash + ./run_unix.bash echo "::endgroup::" diff --git a/.github/workflows/cmake-ubuntu.yml b/.github/workflows/cmake-ubuntu.yml index 0e406ffdc3fa491332c2de69251139ca9e3aa9a2..d68196eedf588bd24c4b75d71d470743e1069a25 100644 --- a/.github/workflows/cmake-ubuntu.yml +++ b/.github/workflows/cmake-ubuntu.yml @@ -57,11 +57,11 @@ jobs: cat meta.yaml echo "::endgroup::" echo "::group::Build" - conda build . -c main -c conda-forge + conda build . echo "::endgroup::" echo "::group::Test" echo $CONDA_PREFIX - conda create -y -n test -c main -c conda-forge -c $CONDA_PREFIX/conda-bld/ trex + conda create -y -n test -c $CONDA_PREFIX/conda-bld/ trex conda activate test pvinfo -opencv_ffmpeg_support pvinfo -opencv_opencl_support @@ -69,5 +69,5 @@ jobs: echo "::group::TestFunctions" conda install -y unzip cd $GITHUB_WORKSPACE/Application/Tests - ./run_ubuntu.bash + ./run_unix.bash echo "::endgroup::" diff --git a/Application/Tests/run_macos.bash b/Application/Tests/run_macos.bash deleted file mode 100755 index 3e79526919f68bb28ec47705ebf8aae10f643099..0000000000000000000000000000000000000000 --- a/Application/Tests/run_macos.bash +++ /dev/null @@ -1,27 +0,0 @@ -PWD=$(pwd)/../../videos - -if ! tgrabs -d "${PWD}" -i "${PWD}/test_frames/frame_%3d.jpg" \ - -o test -threshold 9 -average_samples 100 -averaging_method mode -meta_real_width 2304 -exec "${PWD}/test.settings" \ - -enable_live_tracking -auto_no_results -nowindow -output_format csv; then - echo "TGrabs could not be executed." - exit 1 -fi - -exit_code=0 - -for f in `ls ${PWD}/data/test_fish*.csv`; do - f=$(basename $f .csv) - - echo "Checking $f ..." - if ! git --no-pager diff --word-diff --no-index -- ${PWD}/data/${f}.csv ${PWD}/compare_data/raw/${f}.csv; then - echo "files $f differ from baseline" - exit_code=1 - fi -done - -rm -rf ${PWD}/data - -exit ${exit_code} - -#trex -d "${PWD}" -i test -s "${PWD}/test.settings" -p corrected -auto_apply -auto_quit -auto_no_results -nowindow -#rm -rf ${PWD}/corrected/data \ No newline at end of file diff --git a/Application/Tests/run_ubuntu.bash b/Application/Tests/run_ubuntu.bash deleted file mode 100755 index 5a3fc8df5a10772b21261b2a94344807a3ecefe0..0000000000000000000000000000000000000000 --- a/Application/Tests/run_ubuntu.bash +++ /dev/null @@ -1,23 +0,0 @@ -PWD=$(pwd)/../../videos - -if ! tgrabs -d "${PWD}" -i "${PWD}/test_frames/frame_%3d.jpg" \ - -o test -threshold 9 -average_samples 100 -averaging_method mode -meta_real_width 2304 -exec "${PWD}/test.settings" \ - -enable_live_tracking -auto_no_results -nowindow -output_format csv; then - echo "TGrabs could not be executed." - exit 1 -fi - -for f in `ls ${PWD}/data/test_fish*.csv`; do - f=$(basename $f .csv) - - echo "Checking $f ..." - if ! git --no-pager diff --word-diff --no-index -- ${PWD}/data/${f}.csv ${PWD}/compare_data/raw/${f}.csv; then - echo "files $f differ from baseline" - exit 1 - fi -done - -rm -rf ${PWD}/data - -#trex -d "${PWD}" -i test -s "${PWD}/test.settings" -p corrected -auto_apply -auto_quit -auto_no_results -nowindow -#rm -rf ${PWD}/corrected/data \ No newline at end of file diff --git a/Application/Tests/run_unix.bash b/Application/Tests/run_unix.bash new file mode 100755 index 0000000000000000000000000000000000000000..7c048717201383233b8a7be043816bd000155673 --- /dev/null +++ b/Application/Tests/run_unix.bash @@ -0,0 +1,71 @@ +#!/bin/bash + +PWD=$(pwd)/../../videos + +CMD="tgrabs -d "${PWD}" -i \"${PWD}/test_frames/frame_%3d.jpg\" -o test -threshold 9 -average_samples 100 + -averaging_method mode -meta_real_width 2304 -exec \"${PWD}/test.settings\" + -enable_live_tracking -auto_no_results -output_format csv -nowindow" +echo "Running TGrabs... ${CMD}" +if ! { ${CMD} 2>&1; } > "${PWD}/tgrabs.log"; then + cat "${PWD}/tgrabs.log" + echo "TGrabs could not be executed." + exit_code=1 +else + echo " Scanning files..." + FILES=$(ls ${PWD}/data/test_fish*.csv) + + if [ -z "${FILES}" ]; then + echo "[ERROR] No files found." + exit_code=1 + else + for f in ${FILES}; do + f=$(basename $f .csv) + + echo -e -n "\tChecking $f ..." + if ! git --no-pager diff --word-diff --no-index -- ${PWD}/data/${f}.csv ${PWD}/compare_data/raw/${f}.csv; then + echo "FAIL" + echo "[ERROR] file $f differs from baseline" + exit_code=1 + else + echo 'OK' + fi + done + fi +fi + +rm -rf ${PWD}/data +echo "" +CMD="trex -d \"${PWD}\" -i test -s \"${PWD}/test.settings\" -p corrected -auto_quit -auto_no_results -output_format csv -nowindow" + +echo "Running TRex... ${CMD}" + +if ! { ${CMD} 2>&1; } > "${PWD}/trex.log"; then + cat "${PWD}/trex.log" + echo "TRex could not be executed." + exit_code=1 +else + echo " Scanning files..." + FILES=$(ls ${PWD}/corrected/data/test_fish*.csv) + + if [ -z "${FILES}" ]; then + echo "[ERROR] No files found." + exit_code=1 + else + for f in ${FILES}; do + f=$(basename $f .csv) + + echo -e -n "\tChecking $f ..." + if ! git --no-pager diff --word-diff --no-index -- ${PWD}/corrected/data/${f}.csv ${PWD}/compare_data/raw/${f}.csv; then + echo "FAIL" + echo "[ERROR] corrected file $f differs from baseline" + exit_code=1 + else + echo 'OK' + fi + done + fi +fi + +rm -rf ${PWD}/corrected/data + +exit ${exit_code} diff --git a/Application/learn_static.py b/Application/learn_static.py index be4e2f1600b0e57a3bd6af86dcd3d62573d4891e..d873ec03bd3b551e8b1a4e995cd724f830dd6b7c 100644 --- a/Application/learn_static.py +++ b/Application/learn_static.py @@ -228,7 +228,7 @@ class ValidationCallback(keras.callbacks.Callback): if len(images) == 0: continue - Y = self.model.predict(images) + Y = self.model.predict(tf.cast(images, float)) predictions.append(Y) distance = np.abs(Y - zeros).sum(axis=1) @@ -467,7 +467,7 @@ def predict(): print("error with the shape") indexes = np.array(np.arange(len(train_X)), dtype=np.float32) - output = np.array(model.predict(train_X), dtype=np.float32) + output = np.array(model.predict(tf.cast(train_X, float)), dtype=np.float32) receive(output, indexes) @@ -594,18 +594,21 @@ def start_learning(): callback = ValidationCallback(model, classes, X_test, Y_test, epochs, filename, output_prefix+"_"+str(accumulation_step), output_path, best_accuracy_worst_class, estimate_uniqueness, settings) - validation_data = (tf.cast(X_test, float), Y_test) + validation_data = None #validation_data = tf.data.Dataset.from_tensor_slices((tf.cast(X_test, float), Y_test))#.batch(batch_size) if len(X_test) == 0: validation_data = None + else: + validation_data = tf.data.Dataset.from_tensor_slices((tf.cast(X_test, float), Y_test)).batch(batch_size) - dataset = tf.data.Dataset.from_generator(lambda: datagen.flow(tf.cast(X_train, float), Y_train, batch_size=batch_size), + dataset = tf.data.Dataset.from_generator(lambda: datagen.flow(tf.cast(X_train, float), tf.cast(Y_train, float), batch_size=batch_size), output_types=(tf.float32, tf.float32), output_shapes =(tf.TensorShape([None, int(settings["image_height"]), int(settings["image_width"]), 1]), tf.TensorShape([None, int(len(classes))])) ).repeat()#.shuffle(len(X_train), reshuffle_each_iteration=True) - #dataset = tf.data.Dataset.from_tensor_slices((tf.cast(X_train, float), Y_train)).batch(batch_size) + #dataset = datagen.flow(tf.cast(X_train, float), Y_train, batch_size=batch_size) TRex.log("tf.data.Dataset: "+str(dataset)) + TRex.log("tf.data.Dataset (validation): "+str(validation_data)) history = model.fit(dataset, validation_data=validation_data, steps_per_epoch=per_epoch, diff --git a/conda/build_conda_package.sh b/conda/build_conda_package.sh index 141d1962185b9349a28a9b463e0eb9879be79855..263757472e4a97a20b3a7b9d2f68135a2b852606 100755 --- a/conda/build_conda_package.sh +++ b/conda/build_conda_package.sh @@ -1,5 +1,5 @@ if [ "$(uname)" == "Linux" ]; then - conda build . -c main -c conda-forge + conda build . else conda build . fi diff --git a/conda/meta.yaml b/conda/meta.yaml index c4548bec0d16b7a9cbc27b7a0b9a2d8bba4fc5be..df55da89664db8ee05729d9be1bf77fbc95948f8 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -17,15 +17,13 @@ source: build: script_env: - GITHUB_WORKFLOW - number: 16 + number: 17 string: "{{ hash }}_{{ number }}" run_exports: - {{ pin_compatible('ffmpeg', min_pin='x.x.x', max_pin='x.x.x') }} - {{ pin_compatible('python', min_pin='x.x.x', max_pin='x.x.x') }} - {{ pin_compatible('libgcc-ng', min_pin='x.x.x', max_pin='x.x.x') }} # [linux] - {{ pin_compatible('libstdcxx-ng', min_pin='x.x.x', max_pin='x.x.x') }} # [linux] - ignore_run_exports: - - xorg-libxinerama detect_binary_files_with_prefix: True files_with_prefix: - bin/trex @@ -48,10 +46,6 @@ requirements: - {{ compiler('cxx') }} - cmake >=3.14 - git - - xorg-libxcursor # [linux] - - xorg-libx11 # [linux] - - xorg-libxrandr # [linux] - - xorg-libxinerama # [linux] - {{ cdt('mesa-libgl-devel') }} # [linux] - {{ cdt('mesa-dri-drivers') }} # [linux] - {{ cdt('libselinux') }} # [linux] @@ -95,7 +89,6 @@ requirements: - python # [not arm64] - python=3.8 # [osx and arm64] - nomkl # [osx] - - xorg-libx11 # [linux] - grpcio # [arm64] - h5py # [arm64] - ipython # [arm64] diff --git a/docs/install.rst b/docs/install.rst index 2461970e875b3c8d092c5693ea78f41925e430b6..cf6f2c6caccf56cd539ff4c5d801a8d7674fa80f 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -17,8 +17,7 @@ The easy way (Windows, Linux and Intel macOS) |trex| supports all major platforms. There is an easy way to install |trex| using Anaconda, by creating a new virtual environment (here named ``tracking``, which you can replace):: - conda create -n tracking -c trexing trex # macOS (Intel), Windows - conda create -n tracking -c main -c conda-forge -c trexing trex # Linux (Intel) + conda create -n tracking -c trexing trex # macOS (Intel), Windows, Linux The down-side is that pre-built binaries are compiled with fewer optimzations and features than a manually compiled one (due to compatibility and licensing issues) and thus are slightly slower =(. For example, the conda version does not offer support for Basler cameras. If you need to use |grabs| with machine vision cameras, or need as much speed as possible/the newest version, please consider compiling the software yourself. @@ -68,8 +67,7 @@ This runs ``conda build .``, which builds the program according to all the setti After compilation was successful, |trex| can be installed using:: - conda create -n tracking -c trexing trex # macOS, Windows - conda create -n tracking -c main -c conda-forge -c trexing trex # Linux (Intel) + conda create -n tracking -c trexing trex # macOS, Windows, Linux (Intel) Notice there is a ``-c local``, instead of the ``-c trexing`` from the first section. @@ -94,7 +92,7 @@ As well as the general requirements: The easiest way to ensure that all requirements are met, is by using conda to create a new environment:: - conda create -n tracking -c conda-forge cmake ffmpeg tensorflow=2 cxx-compiler c-compiler glfw mesa-libgl-devel-cos6-x86_64 libxdamage-devel-cos6-x86_64 libxi-devel-cos6-x86_64 libxxf86vm-cos6-x86_64 libselinux-devel-cos6-x86_64 libuuid-devel-cos6-x86_64 mesa-libgl-devel-cos6-x86_64 + conda create -n tracking cmake ffmpeg tensorflow=2 cxx-compiler c-compiler mesa-libgl-devel-cos6-x86_64 libxdamage-devel-cos6-x86_64 libxi-devel-cos6-x86_64 libxxf86vm-cos6-x86_64 libselinux-devel-cos6-x86_64 libuuid-devel-cos6-x86_64 mesa-libgl-devel-cos6-x86_64 If your GPU is supported by TensorFlow, you can modify the above line by appending ``-gpu`` to ``tensorflow`` to get ``tensorflow-gpu=2``. diff --git a/docs/parameters_trex.rst b/docs/parameters_trex.rst index 8370d9858c2b0bb07728a9412fd1d6a52dcdb4df..de915c9324a1fc656a344f193b557e8596090d74 100644 --- a/docs/parameters_trex.rst +++ b/docs/parameters_trex.rst @@ -626,7 +626,7 @@ TRex parameters .. function:: gui_interface_scale(float) - **default value:** 0.75 + **default value:** 1.25 Scales the whole interface. A value greater than 1 will make it smaller. diff --git a/videos/corrected/test.settings b/videos/corrected/test.settings new file mode 100644 index 0000000000000000000000000000000000000000..c8c65f089444a7fa3b0d23d82009781c9a15969b --- /dev/null +++ b/videos/corrected/test.settings @@ -0,0 +1,7 @@ +auto_no_results = true +blob_size_ranges = [[80,400]] +gui_focus_group = [0] +output_format = csv +output_graphs = [["X",["wcentroid"]],["SPEED",["wcentroid"]],["midline_length",["RAW"]]] +track_max_individuals = 8 +track_max_speed = 800 diff --git a/videos/test_weights.npz b/videos/corrected/test_weights.npz similarity index 100% rename from videos/test_weights.npz rename to videos/corrected/test_weights.npz diff --git a/videos/test.pv b/videos/test.pv index 5cd56e904c8b8fed46a42b42758445291a9e81cd..97d1b6da91007a74a88f7c0e5780caad5753181d 100644 Binary files a/videos/test.pv and b/videos/test.pv differ