Skip to content

Commit

Permalink
minor code cleaning (#8844)
Browse files Browse the repository at this point in the history
* minor cleanup
* vcpkg force internal tools to reduce cache misses
* move getopt to 3rdparty
* add a very small test on a couple of platform in CI
  • Loading branch information
cenit authored Sep 27, 2023
1 parent 39b854d commit 9a9fcdb
Show file tree
Hide file tree
Showing 52 changed files with 327 additions and 172,606 deletions.
35 changes: 33 additions & 2 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:

env:
VCPKG_BINARY_SOURCES: 'clear;nuget,vcpkgbinarycache,readwrite'
VCPKG_FORCE_DOWNLOADED_BINARIES: "TRUE"

jobs:
ubuntu-makefile:
Expand Down Expand Up @@ -351,6 +352,12 @@ jobs:
shell: pwsh
run: ${{ github.workspace }}/build.ps1 -ForceCPP -DisableInteractive -DoNotUpdateTOOL

- name: Test on data/dog.jpg
shell: bash
run: >
wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.weights -O ${{ github.workspace }}/yolov4-tiny.weights;
${{ github.workspace }}/build_release/darknet detect ${{ github.workspace }}/cfg/yolov4-tiny.cfg ${{ github.workspace }}/yolov4-tiny.weights ${{ github.workspace }}/data/dog.jpg -dont_show
ubuntu-setup-sh:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -627,16 +634,40 @@ jobs:
run: ${{ github.workspace }}/scripts/setup.ps1 -InstallCUDA


win-intlibs-cpp:
win-vcpkg-base-cpp:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- uses: lukka/get-cmake@latest

- name: 'Setup vcpkg and NuGet artifacts backend'
shell: bash
run: >
git clone --depth 1 https://github.com/microsoft/vcpkg ;
./vcpkg/bootstrap-vcpkg.sh ;
$(./vcpkg/vcpkg fetch nuget | tail -n 1) sources add
-Name "vcpkgbinarycache"
-Source https://93.49.111.10:5555/v3/index.json
- name: Setup NuGet API key if found
shell: bash
env:
BAGET_API_KEY: ${{ secrets.BAGET_API_KEY }}
if: env.BAGET_API_KEY != null
run: >
$(./vcpkg/vcpkg fetch nuget | tail -n 1)
setapikey ${{ secrets.BAGET_API_KEY }}
-Source https://93.49.111.10:5555/v3/index.json
- name: 'Build'
shell: pwsh
run: ${{ github.workspace }}/build.ps1 -ForceCPP -DisableInteractive -DoNotUpdateTOOL
run: ${{ github.workspace }}/build.ps1 -UseVCPKG -ForceLocalVCPKG -DoNotUpdateVCPKG -ForceCPP -DisableInteractive -DoNotUpdateTOOL

- name: Download yolov4-tiny.weights
run: curl.exe -L https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.weights -o ${{ github.workspace }}\yolov4-tiny.weights
- name: Test on data/dog.jpg
run: ${{ github.workspace }}\build_release\darknet.exe detect ${{ github.workspace }}\cfg\yolov4-tiny.cfg ${{ github.workspace }}\yolov4-tiny.weights ${{ github.workspace }}\data\dog.jpg


win-csharp:
Expand Down
25 changes: 23 additions & 2 deletions .github/workflows/on_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [pull_request]

env:
VCPKG_BINARY_SOURCES: 'clear;nuget,vcpkgbinarycache,read'
VCPKG_FORCE_DOWNLOADED_BINARIES: "TRUE"

jobs:
ubuntu-makefile:
Expand Down Expand Up @@ -256,6 +257,12 @@ jobs:
shell: pwsh
run: ${{ github.workspace }}/build.ps1 -ForceCPP -DisableInteractive -DoNotUpdateTOOL

- name: Test on data/dog.jpg
shell: bash
run: >
wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.weights -O ${{ github.workspace }}/yolov4-tiny.weights;
${{ github.workspace }}/build_release/darknet detect ${{ github.workspace }}/cfg/yolov4-tiny.cfg ${{ github.workspace }}/yolov4-tiny.weights ${{ github.workspace }}/data/dog.jpg -dont_show
ubuntu-setup-sh:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -379,16 +386,30 @@ jobs:
run: ${{ github.workspace }}/scripts/setup.ps1 -InstallCUDA


win-intlibs-cpp:
win-vcpkg-base-cpp:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

- uses: lukka/get-cmake@latest

- name: 'Setup vcpkg and NuGet artifacts backend'
shell: bash
run: >
git clone --depth 1 https://github.com/microsoft/vcpkg ;
./vcpkg/bootstrap-vcpkg.sh ;
$(./vcpkg/vcpkg fetch nuget | tail -n 1) sources add
-Name "vcpkgbinarycache"
-Source https://93.49.111.10:5555/v3/index.json
- name: 'Build'
shell: pwsh
run: ${{ github.workspace }}/build.ps1 -ForceCPP -DisableInteractive -DoNotUpdateTOOL
run: ${{ github.workspace }}/build.ps1 -UseVCPKG -ForceLocalVCPKG -DoNotUpdateVCPKG -ForceCPP -DisableInteractive -DoNotUpdateTOOL

- name: Download yolov4-tiny.weights
run: curl.exe -L https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.weights -o ${{ github.workspace }}\yolov4-tiny.weights
- name: Test on data/dog.jpg
run: ${{ github.workspace }}\build_release\darknet.exe detect ${{ github.workspace }}\cfg\yolov4-tiny.cfg ${{ github.workspace }}\yolov4-tiny.weights ${{ github.workspace }}\data\dog.jpg


win-csharp:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.csv
*.out
*.png
*.jpg
*.so
*.exe
*.dll
Expand Down Expand Up @@ -65,4 +66,5 @@ include/darknet/
uselib
uselib_track
darknet
kmeansiou
vcpkg/
File renamed without changes.
File renamed without changes.
19 changes: 17 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ list(APPEND headers
if(NOT MSVC)
list(REMOVE_ITEM headers
${CMAKE_CURRENT_LIST_DIR}/src/gettimeofday.h
${CMAKE_CURRENT_LIST_DIR}/src/getopt.h
)
endif()
#set(exported_headers ${headers})
Expand All @@ -432,10 +431,19 @@ list(REMOVE_ITEM sources
if(NOT MSVC)
list(REMOVE_ITEM sources
${CMAKE_CURRENT_LIST_DIR}/src/gettimeofday.c
${CMAKE_CURRENT_LIST_DIR}/src/getopt.c
)
endif()

if(USE_INTEGRATED_LIBS AND MSVC)
list(APPEND sources
${CMAKE_CURRENT_LIST_DIR}/3rdparty/getopt/getopt.c
${CMAKE_CURRENT_LIST_DIR}/3rdparty/getopt/getopt.h
)
endif()
if((NOT USE_INTEGRATED_LIBS) AND MSVC)
find_package(unofficial-getopt-win32 REQUIRED)
endif()

if(ENABLE_CUDA)
file(GLOB cuda_sources "${CMAKE_CURRENT_LIST_DIR}/src/*.cu")
endif()
Expand Down Expand Up @@ -530,6 +538,13 @@ if(MSVC)
target_link_libraries(dark PUBLIC PThreads4W::PThreads4W)
target_link_libraries(dark PUBLIC wsock32)
target_link_libraries(uselib PRIVATE PThreads4W::PThreads4W)
if(USE_INTEGRATED_LIBS)
target_include_directories(dark PRIVATE ${CMAKE_CURRENT_LIST_DIR}/3rdparty/getopt)
target_include_directories(darknet PRIVATE ${CMAKE_CURRENT_LIST_DIR}/3rdparty/getopt)
else()
target_link_libraries(dark PRIVATE unofficial::getopt-win32::getopt)
target_link_libraries(darknet PRIVATE unofficial::getopt-win32::getopt)
endif()
target_compile_definitions(darknet PRIVATE -D_CRT_RAND_S -DNOMINMAX -D_USE_MATH_DEFINES)
target_compile_definitions(dark PRIVATE -D_CRT_RAND_S -DNOMINMAX -D_USE_MATH_DEFINES)
target_compile_definitions(dark PUBLIC -D_CRT_SECURE_NO_WARNINGS)
Expand Down
3 changes: 3 additions & 0 deletions DarknetConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ find_dependency(Threads)
if(MSVC)
find_dependency(PThreads4W)
set(CMAKE_CXX_FLAGS "/wd4018 /wd4244 /wd4267 /wd4305 ${CMAKE_CXX_FLAGS}")
if(@unofficial-getopt-win32_FOUND@)
find_dependency(unofficial-getopt-win32)
endif()
endif()

if(@OPENMP_FOUND@)
Expand Down
42 changes: 31 additions & 11 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
build
Created By: Stefano Sinigardi
Created Date: February 18, 2019
Last Modified Date: September 10, 2023
Last Modified Date: September 25, 2023
.DESCRIPTION
Build tool using CMake, trying to properly setup the environment around compiler
Expand Down Expand Up @@ -193,10 +193,24 @@ param (

$global:DisableInteractive = $DisableInteractive

$build_ps1_version = "3.5.1"
$build_ps1_version = "3.6.1"
$script_name = $MyInvocation.MyCommand.Name
$utils_psm1_avail = $false

Import-Module -Name $PSScriptRoot/scripts/utils.psm1 -Force
if (Test-Path $PSScriptRoot/scripts/utils.psm1) {
Import-Module -Name $PSScriptRoot/scripts/utils.psm1 -Force
$utils_psm1_avail = $true
}
else {
$utils_psm1_version = "unavail"
$IsWindowsPowerShell = $false
$IsInGitSubmodule = $false
}

if (-Not $utils_psm1_avail) {
$DoNotSetupVS = $true
$ForceCMakeFromVS = $false
}

$ErrorActionPreference = "SilentlyContinue"
Stop-Transcript | out-null
Expand All @@ -219,6 +233,9 @@ if (-Not $BuildInstaller) {
Start-Transcript -Path $BuildLogPath

Write-Host "Build script version ${build_ps1_version}, utils module version ${utils_psm1_version}"
if (-Not $utils_psm1_avail) {
Write-Host "utils.psm1 is not available, so VS integration is forcefully disabled" -ForegroundColor Yellow
}
Write-Host "Working directory: $PSCustomScriptRoot, log file: $BuildLogPath, $script_name is in submodule: $IsInGitSubmodule"

if ((-Not $global:DisableInteractive) -and (-Not $UseVCPKG)) {
Expand Down Expand Up @@ -722,7 +739,7 @@ if ($UseVCPKG -And -Not $ForceLocalVCPKG) {
if (($null -eq $vcpkg_path) -and $UseVCPKG) {
if (-Not (Test-Path "$PWD/vcpkg${VCPKGSuffix}")) {
$shallow_copy = ""
if($ForceOpenCVVersion -eq 0) {
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}"
Expand Down Expand Up @@ -897,13 +914,16 @@ if (-Not $InstallDARKNETthroughVCPKG) {
$AdditionalBuildSetup = $AdditionalBuildSetup + " -DENABLE_DEPLOY_CUSTOM_CMAKE_MODULES:BOOL=ON"
}

if ($ForceVCPKGBuildtreesPath -ne "") {
$AdditionalBuildSetup = $AdditionalBuildSetup + " -DVCPKG_INSTALL_OPTIONS=`"--x-buildtrees-root=$ForceVCPKGBuildtreesPath`" "
New-Item -Path $ForceVCPKGBuildtreesPath -ItemType directory -Force | Out-Null
$vcpkgbuildtreespath = "$ForceVCPKGBuildtreesPath"
}
else {
$vcpkgbuildtreespath = "$vcpkg_path/buildtrees"
if($UseVCPKG) {
if ($ForceVCPKGBuildtreesPath -ne "") {
$AdditionalBuildSetup = $AdditionalBuildSetup + " -DVCPKG_INSTALL_OPTIONS=--clean-buildtrees-after-build;--x-buildtrees-root=`"$ForceVCPKGBuildtreesPath`""
New-Item -Path $ForceVCPKGBuildtreesPath -ItemType directory -Force | Out-Null
$vcpkgbuildtreespath = "$ForceVCPKGBuildtreesPath"
}
else {
$AdditionalBuildSetup = $AdditionalBuildSetup + " -DVCPKG_INSTALL_OPTIONS=--clean-buildtrees-after-build"
$vcpkgbuildtreespath = "$vcpkg_path/buildtrees"
}
}

if ($InstallDARKNETthroughVCPKG) {
Expand Down
Empty file removed results/tmp.txt
Empty file.
4 changes: 2 additions & 2 deletions scripts/deploy-cuda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ elif [[ $(cut -f2 <<< $(lsb_release -i)) == "Ubuntu" ]]; then
distr_name="$(cut -f2 <<< $(lsb_release -i) | tr '[:upper:]' '[:lower:]')$(cut -f2 <<< $(lsb_release -r) | tr -d '.')"
else
echo "Unable to deploy CUDA on this OS, please wait for a future script update"
exit 3
exit 2
fi

script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
Expand All @@ -16,7 +16,7 @@ if [ -f $script_dir/requested_cuda_version.sh ]; then
source $script_dir/requested_cuda_version.sh
else
echo "Unable to find requested_cuda_version.sh script"
exit 1
exit 3
fi

sudo apt-key del 7fa2af80
Expand Down
66 changes: 0 additions & 66 deletions scripts/install_OpenCV4.sh

This file was deleted.

Binary file removed scripts/log_parser/plot.jpg
Binary file not shown.
20 changes: 8 additions & 12 deletions scripts/log_parser/readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#### parsing training log and plot
**Requirement**
1. ** matplotlib needed **
# parsing training log and plot

## Requirements

1. matplotlib

## Usage

**Usage**
1. --source-dir the directory of training log files
2. --save-dir the directory to save loss curve, image and csv file
3. --log-file log file name to be parsed
Expand All @@ -11,11 +14,4 @@

`python log_parser.py --source-dir ./ --save-dir ./ --log-file test.log --show true`

![plot](https://github.com/Adesun/darknet/blob/log_parser/scripts/log_parser/plot.jpg)







![plot](https://github.com/AlexeyAB/darknet/blob/master/scripts/log_parser/test_new.svg)
6 changes: 0 additions & 6 deletions scripts/log_parser/run_log_parser_windows.cmd

This file was deleted.

Loading

0 comments on commit 9a9fcdb

Please sign in to comment.