Skip to content

Commit

Permalink
Merge branch 'dev/alexey/master' into dev/cenit/deprecate_msbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
cenit committed Sep 21, 2023
2 parents 28b1bb3 + 39b854d commit 0b2987f
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 36 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ jobs:
- name: Update apt
run: sudo apt update
- name: Install dependencies
run: sudo apt-get install -y yasm nasm gperf libgles2-mesa-dev libx11-dev libxft-dev libxext-dev libxrandr-dev libxi-dev libxcursor-dev libxdamage-dev libxinerama-dev libdbus-1-dev libxtst-dev
run: sudo apt-get install -y --no-install-recommends yasm nasm gperf libgles2-mesa-dev libx11-dev libxft-dev libxext-dev libxrandr-dev libxi-dev libxcursor-dev libxdamage-dev libxinerama-dev libdbus-1-dev libxtst-dev
- name: Clean downloads
run: sudo apt-get clean

- name: 'Install CUDA'
run: ${{ github.workspace }}/scripts/deploy-cuda.sh
Expand All @@ -101,7 +103,7 @@ jobs:
- name: 'Setup vcpkg and NuGet artifacts backend'
shell: bash
run: >
git clone https://github.com/microsoft/vcpkg ;
git clone --depth 1 https://github.com/microsoft/vcpkg ;
./vcpkg/bootstrap-vcpkg.sh ;
mono $(./vcpkg/vcpkg fetch nuget | tail -n 1) sources add
-Name "vcpkgbinarycache"
Expand Down Expand Up @@ -154,7 +156,9 @@ jobs:
- name: Update apt
run: sudo apt update
- name: Install dependencies
run: sudo apt-get install -y yasm nasm gperf libgles2-mesa-dev libx11-dev libxft-dev libxext-dev libxrandr-dev libxi-dev libxcursor-dev libxdamage-dev libxinerama-dev libdbus-1-dev libxtst-dev
run: sudo apt-get install -y --no-install-recommends yasm nasm gperf libgles2-mesa-dev libx11-dev libxft-dev libxext-dev libxrandr-dev libxi-dev libxcursor-dev libxdamage-dev libxinerama-dev libdbus-1-dev libxtst-dev
- name: Clean downloads
run: sudo apt-get clean

- name: 'Install CUDA'
run: ${{ github.workspace }}/scripts/deploy-cuda.sh
Expand Down Expand Up @@ -205,7 +209,9 @@ jobs:
- name: Update apt
run: sudo apt update
- name: Install dependencies
run: sudo apt-get install -y yasm nasm gperf libgles2-mesa-dev libx11-dev libxft-dev libxext-dev libxrandr-dev libxi-dev libxcursor-dev libxdamage-dev libxinerama-dev libdbus-1-dev libxtst-dev
run: sudo apt-get install -y --no-install-recommends yasm nasm gperf libgles2-mesa-dev libx11-dev libxft-dev libxext-dev libxrandr-dev libxi-dev libxcursor-dev libxdamage-dev libxinerama-dev libdbus-1-dev libxtst-dev
- name: Clean downloads
run: sudo apt-get clean

- name: 'Install CUDA'
run: ${{ github.workspace }}/scripts/deploy-cuda.sh
Expand Down Expand Up @@ -354,7 +360,7 @@ jobs:
- name: 'Setup vcpkg and NuGet artifacts backend'
shell: bash
run: >
git clone https://github.com/microsoft/vcpkg ;
git clone --depth 1 https://github.com/microsoft/vcpkg ;
./vcpkg/bootstrap-vcpkg.sh ;
mono $(./vcpkg/vcpkg fetch nuget | tail -n 1) sources add
-Name "vcpkgbinarycache"
Expand Down Expand Up @@ -392,7 +398,7 @@ jobs:
- name: 'Setup vcpkg and NuGet artifacts backend'
shell: bash
run: >
git clone https://github.com/microsoft/vcpkg ;
git clone --depth 1 https://github.com/microsoft/vcpkg ;
./vcpkg/bootstrap-vcpkg.sh ;
mono $(./vcpkg/vcpkg fetch nuget | tail -n 1) sources add
-Name "vcpkgbinarycache"
Expand Down Expand Up @@ -488,7 +494,7 @@ jobs:
- name: 'Setup vcpkg and NuGet artifacts backend'
shell: bash
run: >
git clone https://github.com/microsoft/vcpkg ;
git clone --depth 1 https://github.com/microsoft/vcpkg ;
./vcpkg/bootstrap-vcpkg.sh ;
$(./vcpkg/vcpkg fetch nuget | tail -n 1) sources add
-Name "vcpkgbinarycache"
Expand Down Expand Up @@ -538,7 +544,7 @@ jobs:
- name: 'Setup vcpkg and NuGet artifacts backend'
shell: bash
run: >
git clone https://github.com/microsoft/vcpkg ;
git clone --depth 1 https://github.com/microsoft/vcpkg ;
./vcpkg/bootstrap-vcpkg.sh ;
$(./vcpkg/vcpkg fetch nuget | tail -n 1) sources add
-Name "vcpkgbinarycache"
Expand Down Expand Up @@ -600,7 +606,7 @@ jobs:
- name: 'Setup vcpkg and NuGet artifacts backend'
shell: bash
run: >
git clone https://github.com/microsoft/vcpkg ;
git clone --depth 1 https://github.com/microsoft/vcpkg ;
./vcpkg/bootstrap-vcpkg.sh ;
$(./vcpkg/vcpkg fetch nuget | tail -n 1) sources add
-Name "vcpkgbinarycache"
Expand Down
22 changes: 14 additions & 8 deletions .github/workflows/on_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ jobs:
- name: Update apt
run: sudo apt update
- name: Install dependencies
run: sudo apt-get install -y yasm nasm gperf libgles2-mesa-dev libx11-dev libxft-dev libxext-dev libxrandr-dev libxi-dev libxcursor-dev libxdamage-dev libxinerama-dev libdbus-1-dev libxtst-dev
run: sudo apt-get install -y --no-install-recommends yasm nasm gperf libgles2-mesa-dev libx11-dev libxft-dev libxext-dev libxrandr-dev libxi-dev libxcursor-dev libxdamage-dev libxinerama-dev libdbus-1-dev libxtst-dev
- name: Clean downloads
run: sudo apt-get clean

- name: 'Install CUDA'
run: ${{ github.workspace }}/scripts/deploy-cuda.sh
Expand All @@ -87,7 +89,7 @@ jobs:
- name: 'Setup vcpkg and NuGet artifacts backend'
shell: bash
run: >
git clone https://github.com/microsoft/vcpkg ;
git clone --depth 1 https://github.com/microsoft/vcpkg ;
./vcpkg/bootstrap-vcpkg.sh ;
mono $(./vcpkg/vcpkg fetch nuget | tail -n 1) sources add
-Name "vcpkgbinarycache"
Expand All @@ -113,7 +115,9 @@ jobs:
- name: Update apt
run: sudo apt update
- name: Install dependencies
run: sudo apt-get install -y yasm nasm gperf libgles2-mesa-dev libx11-dev libxft-dev libxext-dev libxrandr-dev libxi-dev libxcursor-dev libxdamage-dev libxinerama-dev libdbus-1-dev libxtst-dev
run: sudo apt-get install -y --no-install-recommends yasm nasm gperf libgles2-mesa-dev libx11-dev libxft-dev libxext-dev libxrandr-dev libxi-dev libxcursor-dev libxdamage-dev libxinerama-dev libdbus-1-dev libxtst-dev
- name: Clean downloads
run: sudo apt-get clean

- name: 'Install CUDA'
run: ${{ github.workspace }}/scripts/deploy-cuda.sh
Expand Down Expand Up @@ -154,7 +158,9 @@ jobs:
- name: Update apt
run: sudo apt update
- name: Install dependencies
run: sudo apt-get install -y yasm nasm gperf libgles2-mesa-dev libx11-dev libxft-dev libxext-dev libxrandr-dev libxi-dev libxcursor-dev libxdamage-dev libxinerama-dev libdbus-1-dev libxtst-dev
run: sudo apt-get install -y --no-install-recommends yasm nasm gperf libgles2-mesa-dev libx11-dev libxft-dev libxext-dev libxrandr-dev libxi-dev libxcursor-dev libxdamage-dev libxinerama-dev libdbus-1-dev libxtst-dev
- name: Clean downloads
run: sudo apt-get clean

- name: 'Install CUDA'
run: ${{ github.workspace }}/scripts/deploy-cuda.sh
Expand Down Expand Up @@ -259,7 +265,7 @@ jobs:
- name: 'Setup vcpkg and NuGet artifacts backend'
shell: bash
run: >
git clone https://github.com/microsoft/vcpkg ;
git clone --depth 1 https://github.com/microsoft/vcpkg ;
./vcpkg/bootstrap-vcpkg.sh ;
mono $(./vcpkg/vcpkg fetch nuget | tail -n 1) sources add
-Name "vcpkgbinarycache"
Expand All @@ -283,7 +289,7 @@ jobs:
- name: 'Setup vcpkg and NuGet artifacts backend'
shell: bash
run: >
git clone https://github.com/microsoft/vcpkg ;
git clone --depth 1 https://github.com/microsoft/vcpkg ;
./vcpkg/bootstrap-vcpkg.sh ;
mono $(./vcpkg/vcpkg fetch nuget | tail -n 1) sources add
-Name "vcpkgbinarycache"
Expand Down Expand Up @@ -331,7 +337,7 @@ jobs:
- name: 'Setup vcpkg and NuGet artifacts backend'
shell: bash
run: >
git clone https://github.com/microsoft/vcpkg ;
git clone --depth 1 https://github.com/microsoft/vcpkg ;
./vcpkg/bootstrap-vcpkg.sh ;
$(./vcpkg/vcpkg fetch nuget | tail -n 1) sources add
-Name "vcpkgbinarycache"
Expand Down Expand Up @@ -362,7 +368,7 @@ jobs:
- name: 'Setup vcpkg and NuGet artifacts backend'
shell: bash
run: >
git clone https://github.com/microsoft/vcpkg ;
git clone --depth 1 https://github.com/microsoft/vcpkg ;
./vcpkg/bootstrap-vcpkg.sh ;
$(./vcpkg/vcpkg fetch nuget | tail -n 1) sources add
-Name "vcpkgbinarycache"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ If you customize build with CMake GUI, darknet executable will be installed in y
`./darknet detector test cfg/coco.data cfg/yolov4.cfg yolov4.weights -ext_output -dont_show -out result.json < data/train.txt`
- To process a list of images `data/train.txt` and save results of detection to `result.txt` use:
`./darknet detector test cfg/coco.data cfg/yolov4.cfg yolov4.weights -dont_show -ext_output < data/train.txt > result.txt`
- To process a video and output results to a json file use: `darknet.exe detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights file.mp4 -dont_show -json_file_output results.json`
- Pseudo-labelling - to process a list of images `data/new_train.txt` and save results of detection in Yolo training format for each image as label `<image_name>.txt` (in this way you can increase the amount of training data) use:
`./darknet detector test cfg/coco.data cfg/yolov4.cfg yolov4.weights -thresh 0.25 -dont_show -save_labels < data/new_train.txt`
- To calculate anchors: `./darknet detector calc_anchors data/obj.data -num_of_clusters 9 -width 416 -height 416`
Expand Down
6 changes: 5 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,11 @@ if ($UseVCPKG -And -Not $ForceLocalVCPKG) {
}
if (($null -eq $vcpkg_path) -and $UseVCPKG) {
if (-Not (Test-Path "$PWD/vcpkg${VCPKGSuffix}")) {
$proc = Start-Process -NoNewWindow -PassThru -FilePath $GIT_EXE -ArgumentList "clone https://github.com/microsoft/vcpkg vcpkg${VCPKGSuffix}"
$shallow_copy = ""
if($ForceOpenCVVersion -eq 0) {
$shallow_copy = " --depth 1 "
}
$proc = Start-Process -NoNewWindow -PassThru -FilePath $GIT_EXE -ArgumentList "clone $shallow_copy https://github.com/microsoft/vcpkg vcpkg${VCPKGSuffix}"
$handle = $proc.Handle
$proc.WaitForExit()
$exitCode = $proc.ExitCode
Expand Down
12 changes: 7 additions & 5 deletions scripts/deploy-cuda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ sudo apt-key del 7fa2af80
wget https://developer.download.nvidia.com/compute/cuda/repos/$distr_name/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
sudo apt-get install -y build-essential g++
sudo apt-get install -y apt-transport-https ca-certificates gnupg software-properties-common wget
sudo apt-get install -y zlib1g
sudo apt-get install -y --no-install-recommends build-essential g++
sudo apt-get install -y --no-install-recommends apt-transport-https ca-certificates gnupg software-properties-common wget
sudo apt-get install -y --no-install-recommends zlib1g
sudo apt-get dist-upgrade -y
sudo apt-get install -y --no-install-recommends cuda-${CUDA_VERSION_DASHED}
sudo apt-get install -y libcudnn8
sudo apt-get install -y libcudnn8-dev
sudo apt-get install -y --no-install-recommends libcudnn8
sudo apt-get install -y --no-install-recommends libcudnn8-dev

sudo rm -rf /usr/local/cuda
sudo ln -s /usr/local/cuda-${CUDA_VERSION} /usr/local/cuda

sudo apt-get clean
15 changes: 8 additions & 7 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,21 @@ elif [[ $(cut -f2 <<< $(lsb_release -i)) == "Ubuntu" ]]; then
if [ "$install_tools" = true ] ; then
echo "Installing tools"
sudo apt-get update
sudo apt-get install -y git ninja-build build-essential g++ nasm yasm gperf
sudo apt-get install -y apt-transport-https ca-certificates gnupg software-properties-common wget
sudo apt-get install -y libgles2-mesa-dev libx11-dev libxft-dev libxext-dev libxrandr-dev libxi-dev libxcursor-dev libxdamage-dev libxinerama-dev libdbus-1-dev libxtst-dev
sudo apt-get install -y --no-install-recommends git ninja-build build-essential g++ nasm yasm gperf
sudo apt-get install -y --no-install-recommends apt-transport-https ca-certificates gnupg software-properties-common wget
sudo apt-get install -y --no-install-recommends libgles2-mesa-dev libx11-dev libxft-dev libxext-dev libxrandr-dev libxi-dev libxcursor-dev libxdamage-dev libxinerama-dev libdbus-1-dev libxtst-dev
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
sudo apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(cut -f2 <<< $(lsb_release -c)) main"
wget -q https://packages.microsoft.com/config/ubuntu/$(cut -f2 <<< $(lsb_release -r))/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get dist-upgrade -y
sudo apt-get install -y cmake
sudo apt-get install -y powershell
sudo apt-get install -y curl zip unzip tar
sudo apt-get install -y pkg-config autoconf libtool bison
sudo apt-get install -y --no-install-recommends cmake
sudo apt-get install -y --no-install-recommends powershell
sudo apt-get install -y --no-install-recommends curl zip unzip tar
sudo apt-get install -y --no-install-recommends pkg-config autoconf libtool bison
sudo apt-get clean
fi
else
if [ "$install_cuda" = true ] ; then
Expand Down
3 changes: 2 additions & 1 deletion src/coco.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ void run_coco(int argc, char **argv)
int cam_index = find_int_arg(argc, argv, "-c", 0);
int frame_skip = find_int_arg(argc, argv, "-s", 0);
int ext_output = find_arg(argc, argv, "-ext_output");
char *json_file_output = find_char_arg(argc, argv, "-json_file_output", 0);

if(argc < 4){
fprintf(stderr, "usage: %s %s [train/test/valid] [cfg] [weights (optional)]\n", argv[0], argv[1]);
Expand All @@ -412,5 +413,5 @@ void run_coco(int argc, char **argv)
else if(0==strcmp(argv[2], "valid")) validate_coco(cfg, weights);
else if(0==strcmp(argv[2], "recall")) validate_coco_recall(cfg, weights);
else if(0==strcmp(argv[2], "demo")) demo(cfg, weights, thresh, hier_thresh, cam_index, filename, coco_classes, 80, 1, frame_skip,
prefix, out_filename, mjpeg_port, 0, json_port, dont_show, ext_output, 0, 0, 0, 0, 0);
prefix, out_filename, mjpeg_port, 0, json_port, dont_show, ext_output, 0, 0, 0, 0, 0, json_file_output);
}
28 changes: 26 additions & 2 deletions src/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ double get_wall_time()

void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int cam_index, const char *filename, char **names, int classes, int avgframes,
int frame_skip, char *prefix, char *out_filename, int mjpeg_port, int dontdraw_bbox, int json_port, int dont_show, int ext_output, int letter_box_in, int time_limit_sec, char *http_post_host,
int benchmark, int benchmark_layers)
int benchmark, int benchmark_layers, char *json_file_output)
{
if (avgframes < 1) avgframes = 1;
avg_frames = avgframes;
Expand All @@ -157,6 +157,15 @@ void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int
demo_thresh = thresh;
demo_ext_output = ext_output;
demo_json_port = json_port;
char *json_buf = NULL;
FILE* json_file = NULL;

if (json_file_output) {
json_file = fopen(json_file_output, "wb");
char *tmp = "[\n";
fwrite(tmp, sizeof(char), strlen(tmp), json_file);
}

printf("Demo\n");
net = parse_network_cfg_custom(cfgfile, 1, 1); // set batch=1
if(weightfile){
Expand Down Expand Up @@ -290,6 +299,16 @@ void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int
send_json(local_dets, local_nboxes, l.classes, demo_names, frame_id, demo_json_port, timeout);
}

if (json_file_output) {
if (json_buf) {
char *tmp = ", \n";
fwrite(tmp, sizeof(char), strlen(tmp), json_file);
}
json_buf = detection_to_json(local_dets, local_nboxes, l.classes, demo_names, frame_id, NULL);
fwrite(json_buf, sizeof(char), strlen(json_buf), json_file);
free(json_buf);
}

//char *http_post_server = "webhook.site/898bbd9b-0ddd-49cf-b81d-1f56be98d870";
if (http_post_host && !send_http_post_once) {
int timeout = 3; // 3 seconds
Expand Down Expand Up @@ -396,6 +415,11 @@ void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int
printf("output_video_writer closed. \n");
}

if (json_file_output) {
char *tmp = "\n]";
fwrite(tmp, sizeof(char), strlen(tmp), json_file);
fclose(json_file);
}
this_thread_sleep_for(thread_wait_ms);

custom_join(detect_thread, 0);
Expand All @@ -420,7 +444,7 @@ void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int
#else
void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int cam_index, const char *filename, char **names, int classes, int avgframes,
int frame_skip, char *prefix, char *out_filename, int mjpeg_port, int dontdraw_bbox, int json_port, int dont_show, int ext_output, int letter_box_in, int time_limit_sec, char *http_post_host,
int benchmark, int benchmark_layers)
int benchmark, int benchmark_layers, char *json_file_output)
{
fprintf(stderr, "Demo needs OpenCV for webcam images.\n");
}
Expand Down
2 changes: 1 addition & 1 deletion src/demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
extern "C" {
#endif
void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int cam_index, const char *filename, char **names, int classes, int avgframes,
int frame_skip, char *prefix, char *out_filename, int mjpeg_port, int dontdraw_bbox, int json_port, int dont_show, int ext_output, int letter_box_in, int time_limit_sec, char *http_post_host, int benchmark, int benchmark_layers);
int frame_skip, char *prefix, char *out_filename, int mjpeg_port, int dontdraw_bbox, int json_port, int dont_show, int ext_output, int letter_box_in, int time_limit_sec, char *http_post_host, int benchmark, int benchmark_layers, char *json_file_output);
#ifdef __cplusplus
}
#endif
Expand Down
3 changes: 2 additions & 1 deletion src/detector.c
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,7 @@ void run_detector(int argc, char **argv)
char *http_post_host = find_char_arg(argc, argv, "-http_post_host", 0);
int time_limit_sec = find_int_arg(argc, argv, "-time_limit_sec", 0);
char *out_filename = find_char_arg(argc, argv, "-out_filename", 0);
char *json_file_output = find_char_arg(argc, argv, "-json_file_output", 0);
char *outfile = find_char_arg(argc, argv, "-out", 0);
char *prefix = find_char_arg(argc, argv, "-prefix", 0);
float thresh = find_float_arg(argc, argv, "-thresh", .25); // 0.24
Expand Down Expand Up @@ -2048,7 +2049,7 @@ void run_detector(int argc, char **argv)
if (strlen(filename) > 0)
if (filename[strlen(filename) - 1] == 0x0d) filename[strlen(filename) - 1] = 0;
demo(cfg, weights, thresh, hier_thresh, cam_index, filename, names, classes, avgframes, frame_skip, prefix, out_filename,
mjpeg_port, dontdraw_bbox, json_port, dont_show, ext_output, letter_box, time_limit_sec, http_post_host, benchmark, benchmark_layers);
mjpeg_port, dontdraw_bbox, json_port, dont_show, ext_output, letter_box, time_limit_sec, http_post_host, benchmark, benchmark_layers, json_file_output);

free_list_contents_kvp(options);
free_list(options);
Expand Down
3 changes: 2 additions & 1 deletion src/yolo.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ void run_yolo(int argc, char **argv)
int cam_index = find_int_arg(argc, argv, "-c", 0);
int frame_skip = find_int_arg(argc, argv, "-s", 0);
int ext_output = find_arg(argc, argv, "-ext_output");
char *json_file_output = find_char_arg(argc, argv, "-json_file_output", 0);
if(argc < 4){
fprintf(stderr, "usage: %s %s [train/test/valid] [cfg] [weights (optional)]\n", argv[0], argv[1]);
return;
Expand All @@ -366,5 +367,5 @@ void run_yolo(int argc, char **argv)
else if(0==strcmp(argv[2], "valid")) validate_yolo(cfg, weights);
else if(0==strcmp(argv[2], "recall")) validate_yolo_recall(cfg, weights);
else if(0==strcmp(argv[2], "demo")) demo(cfg, weights, thresh, hier_thresh, cam_index, filename, voc_names, 20, 1, frame_skip,
prefix, out_filename, mjpeg_port, 0, json_port, dont_show, ext_output, 0, 0, 0, 0, 0);
prefix, out_filename, mjpeg_port, 0, json_port, dont_show, ext_output, 0, 0, 0, 0, 0, json_file_output);
}

0 comments on commit 0b2987f

Please sign in to comment.