From b751bac17505a742f149ada81d75689b5e692cde Mon Sep 17 00:00:00 2001 From: AlexeyAB Date: Tue, 5 Mar 2019 02:15:44 +0300 Subject: [PATCH] Fixed mAP calculation for CRNN layer during training --- README.md | 2 +- scripts/windows/otb_get_labels.sh | 50 +++++++++++++++++++++++ scripts/windows/win_get_otb_datasets.cmd | 18 ++++++++ scripts/windows/win_get_otb_human3.cmd | 22 ---------- scripts/windows/windows_otb_get_labels.sh | 28 ------------- src/crnn_layer.c | 2 +- 6 files changed, 70 insertions(+), 52 deletions(-) create mode 100644 scripts/windows/otb_get_labels.sh create mode 100644 scripts/windows/win_get_otb_datasets.cmd delete mode 100644 scripts/windows/win_get_otb_human3.cmd delete mode 100644 scripts/windows/windows_otb_get_labels.sh diff --git a/README.md b/README.md index dd45cd40..245a0f06 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ * [Explanations in issues](https://github.com/AlexeyAB/darknet/issues?q=is%3Aopen+is%3Aissue+label%3AExplanations) 0. [Improvements in this repository](#improvements-in-this-repository) -1. [How to use](#how-to-use) +1. [How to use](#how-to-use-on-the-command-line) 2. [How to compile on Linux](#how-to-compile-on-linux) 3. How to compile on Windows * [Using vcpkg](#how-to-compile-on-windows-using-vcpkg) diff --git a/scripts/windows/otb_get_labels.sh b/scripts/windows/otb_get_labels.sh new file mode 100644 index 00000000..43e53e4f --- /dev/null +++ b/scripts/windows/otb_get_labels.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +dataset=$1 +w=$2 +h=$3 + +# Parameters: Human3, CarScale, Human6, Biker +#w=480 +#h=640 +IFS=',' + +export LC_NUMERIC="en_US.UTF-8" + +wd=`pwd` +dataset_path="data/$dataset" + +class_id=0 +num=1 + +mkdir data +wget http://cvlab.hanyang.ac.kr/tracker_benchmark/seq/$dataset.zip + +unzip -o $dataset.zip -d data + +sed -i.bak 's/\o11/,/g' $dataset_path/groundtruth_rect.txt +sed -i.bak 's/\o11/,/g' $dataset_path/groundtruth_rect.txt +dos2unix $dataset_path/groundtruth_rect.txt + +while read -r left right width height; do +filename=$(printf "$dataset_path/img/%04d.txt" $num) +#rm $filename.txt +echo "$class_id " > $filename +printf "%.5f " "$(($((left + width/2)) * 100000 / $w))e-5" >> $filename +printf "%.5f " "$(($((right + height/2)) * 100000 / $h))e-5" >> $filename +printf "%.5f " "$(($((width)) * 100000 / $w))e-5" >> $filename +printf "%.5f " "$(($((height)) * 100000 / $h))e-5" >> $filename +num=$((num + 1)) +done < $dataset_path/groundtruth_rect.txt + +echo "$dataset" > $dataset_path/otb.names + + +find $dataset_path/img -name \*.jpg > data/$dataset/train.txt + +echo "classes = 1" > data/otb_$dataset.data +echo "train = data/$dataset/train.txt" >> data/otb_$dataset.data +echo "valid = data/$dataset/train.txt" >> data/otb_$dataset.data +echo "names = $dataset_path/otb.names" >> data/otb_$dataset.data +echo "backup = backup/" >> data/otb_$dataset.data +echo "results= results/" >> data/otb_$dataset.data \ No newline at end of file diff --git a/scripts/windows/win_get_otb_datasets.cmd b/scripts/windows/win_get_otb_datasets.cmd new file mode 100644 index 00000000..8c12249b --- /dev/null +++ b/scripts/windows/win_get_otb_datasets.cmd @@ -0,0 +1,18 @@ +echo Run install_cygwin.cmd before: + +rem http://cvlab.hanyang.ac.kr/tracker_benchmark/datasets.html + +c:\cygwin64\bin\bash -l -c "cd %CD:\=/%/; echo $PWD" + +c:\cygwin64\bin\dos2unix "%CD:\=/%/otb_get_labels.sh" + + +c:\cygwin64\bin\bash -l -c "cd %CD:\=/%/; %CD:\=/%/otb_get_labels.sh Suv 320 240" + +c:\cygwin64\bin\bash -l -c "cd %CD:\=/%/; %CD:\=/%/otb_get_labels.sh Liquor 640 480" + +c:\cygwin64\bin\bash -l -c "cd %CD:\=/%/; %CD:\=/%/otb_get_labels.sh Freeman4 360 240" + +c:\cygwin64\bin\bash -l -c "cd %CD:\=/%/; %CD:\=/%/otb_get_labels.sh Human3 480 640" + +pause \ No newline at end of file diff --git a/scripts/windows/win_get_otb_human3.cmd b/scripts/windows/win_get_otb_human3.cmd deleted file mode 100644 index 11fc5e30..00000000 --- a/scripts/windows/win_get_otb_human3.cmd +++ /dev/null @@ -1,22 +0,0 @@ -echo Run install_cygwin.cmd before: - -rem http://cvlab.hanyang.ac.kr/tracker_benchmark/datasets.html - -c:\cygwin64\bin\bash -l -c "cd %CD:\=/%/; echo $PWD" - - -c:\cygwin64\bin\wget http://cvlab.hanyang.ac.kr/tracker_benchmark/seq/Human3.zip - -c:\cygwin64\bin\unzip -o "%CD:\=/%/Human3.zip" - - - -c:\cygwin64\bin\dos2unix "%CD:\=/%/windows_otb_get_labels.sh" - -c:\cygwin64\bin\bash -l -c "cd %CD:\=/%/; %CD:\=/%/windows_otb_get_labels.sh" - -rem c:\cygwin64\bin\find "%CD:\=/%/img" -name \*.jpg > otb_train.txt - - - -pause \ No newline at end of file diff --git a/scripts/windows/windows_otb_get_labels.sh b/scripts/windows/windows_otb_get_labels.sh deleted file mode 100644 index b707de09..00000000 --- a/scripts/windows/windows_otb_get_labels.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -export LC_NUMERIC="en_US.UTF-8" - -wd=`pwd` -IFS=',' - -dataset="Human3" -class_id=0 -w=480 -h=640 -num=1 - -while read -a line; do -filename=$(printf "$dataset/img/%04d.txt" $num) -#rm $filename.txt -echo "$class_id " > $filename -printf "%.5f " "$(($((line[0] + line[2]/2)) * 100000 / $w))e-5" >> $filename -printf "%.5f " "$(($((line[1] + line[3]/2)) * 100000 / $h))e-5" >> $filename -printf "%.5f " "$(($((line[2])) * 100000 / $w))e-5" >> $filename -printf "%.5f " "$(($((line[3])) * 100000 / $h))e-5" >> $filename -num=$((num + 1)) -done < $dataset/groundtruth_rect.txt - -echo "$dataset" > $dataset/otb.names - - -find $dataset/img -name \*.jpg > otb_train.txt \ No newline at end of file diff --git a/src/crnn_layer.c b/src/crnn_layer.c index 40de1001..0fc6da72 100644 --- a/src/crnn_layer.c +++ b/src/crnn_layer.c @@ -263,7 +263,7 @@ void forward_crnn_layer_gpu(layer l, network_state state) s.train = state.train; s.workspace = state.workspace; s.net = state.net; - if(!state.train) s.index = state.index; // use TC only for detection + //if(!state.train) s.index = state.index; // don't use TC at all (especially without cuda_convert_f32_to_f16() ) int i; layer input_layer = *(l.input_layer); layer self_layer = *(l.self_layer);