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 Aug 31, 2023
2 parents f8e3685 + 291cdb9 commit 9b095f7
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 37 deletions.
52 changes: 47 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ option(ENABLE_ZED_CAMERA "Enable ZED Camera support" ON)
option(ENABLE_VCPKG_INTEGRATION "Enable VCPKG integration" OFF)
option(ENABLE_DEPLOY_CUSTOM_CMAKE_MODULES "Copy custom CMake modules for downstream integration" OFF)
option(ENABLE_CSHARP_WRAPPER "Enable building a csharp wrapper" OFF)
option(ENABLE_INSTALLER "Enable building an installer" OFF)
option(VCPKG_BUILD_OPENCV_WITH_CUDA "Build OpenCV with CUDA extension integration" ON)
option(VCPKG_USE_OPENCV2 "Use legacy OpenCV 2" OFF)
option(VCPKG_USE_OPENCV3 "Use legacy OpenCV 3" OFF)
Expand Down Expand Up @@ -161,12 +162,17 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Install prefix" FORCE)
if(NOT ENABLE_INSTALLER)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Install prefix" FORCE)
endif()
set(INSTALL_BIN_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Path where exe and dll will be installed")
set(INSTALL_LIB_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Path where lib will be installed")
else()
set(INSTALL_BIN_DIR "bin" CACHE PATH "Path where exe and dll will be installed")
set(INSTALL_LIB_DIR "lib" CACHE PATH "Path where lib will be installed")
endif()

set(INSTALL_BIN_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Path where exe and dll will be installed")
set(INSTALL_LIB_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Path where lib will be installed")
set(INSTALL_INCLUDE_DIR "include/darknet" CACHE PATH "Path where headers will be installed")
set(INSTALL_CMAKE_DIR "share/darknet" CACHE PATH "Path where cmake configs will be installed")

Expand Down Expand Up @@ -383,7 +389,6 @@ else()
set(ENABLE_ZED_CAMERA "FALSE" CACHE BOOL "Enable ZED Camera support" FORCE)
endif()

# Make relative paths absolute (needed later on)
foreach(p LIB BIN INCLUDE CMAKE)
set(var INSTALL_${p}_DIR)
if(NOT IS_ABSOLUTE "${${var}}")
Expand Down Expand Up @@ -465,6 +470,9 @@ if(BUILD_AS_CPP)
set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/src/darknet.c PROPERTIES LANGUAGE CXX)
set_target_properties(darknet PROPERTIES LINKER_LANGUAGE CXX)
endif()
if(MSVC)
target_sources(darknet PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src/darknet.rc)
endif()

add_executable(kmeansiou ${CMAKE_CURRENT_LIST_DIR}/scripts/kmeansiou.c)
if(MATH_LIBRARY)
Expand Down Expand Up @@ -655,3 +663,37 @@ install(
PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
DESTINATION ${INSTALL_BIN_DIR}
)

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json VCPKG_JSON_STRING)
string(JSON CPACK_PACKAGE_NAME GET ${VCPKG_JSON_STRING} name)
string(JSON CPACK_BUNDLE_NAME GET ${VCPKG_JSON_STRING} name)
string(JSON CPACK_PACKAGE_HOMEPAGE_URL GET ${VCPKG_JSON_STRING} homepage)
string(JSON CPACK_PACKAGE_DESCRIPTION GET ${VCPKG_JSON_STRING} description)
string(JSON CPACK_NSIS_DISPLAY_NAME GET ${VCPKG_JSON_STRING} description)
string(JSON CPACK_NSIS_PACKAGE_NAME GET ${VCPKG_JSON_STRING} description)
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE)
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/src/darknet.ico")
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/src/darknet.ico")
set(CPACK_BUNDLE_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/src/darknet.ico")

if(UNIX AND NOT APPLE)
find_program(LSB_RELEASE_EXEC lsb_release)
execute_process(COMMAND ${LSB_RELEASE_EXEC} -is
OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(LSB_RELEASE_ID_SHORT STREQUAL "Ubuntu")
set(CPACK_GENERATOR "DEB")
else()
set(CPACK_GENERATOR "RPM")
endif()
elseif(WIN32)
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_NSIS_MODIFY_PATH "ON")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
set(CPACK_GENERATOR "NSIS")
endif()

include(CPack)
endif()
36 changes: 24 additions & 12 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: August 10, 2023
Last Modified Date: August 31, 2023
.DESCRIPTION
Build tool using CMake, trying to properly setup the environment around compiler
Expand Down Expand Up @@ -110,6 +110,9 @@ Download pre-trained weight files
.PARAMETER Use32bitTriplet
Use 32 bit triplet for target build (windows-only)
.PARAMETER BuildInstaller
Build an installer using CPack
.PARAMETER ForceGCCVersion
Force a specific GCC version
Expand Down Expand Up @@ -182,14 +185,15 @@ param (
[switch]$EnableCSharpWrapper = $false,
[switch]$DownloadWeights = $false,
[switch]$Use32bitTriplet = $false,
[switch]$BuildInstaller = $false,
[Int32]$ForceGCCVersion = 0,
[Int32]$NumberOfBuildWorkers = 8,
[string]$AdditionalBuildSetup = "" # "-DCMAKE_CUDA_ARCHITECTURES=30"
)

$global:DisableInteractive = $DisableInteractive

$build_ps1_version = "3.4.1"
$build_ps1_version = "3.5.0"
$script_name = $MyInvocation.MyCommand.Name

Import-Module -Name $PSScriptRoot/scripts/utils.psm1 -Force
Expand Down Expand Up @@ -881,6 +885,15 @@ 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 ($InstallDARKNETthroughVCPKG) {
if ($ForceVCPKGDarknetHEAD) {
$headMode = " --head "
Expand Down Expand Up @@ -979,10 +992,6 @@ else {
Write-Host "-- Copying $_ to $DebugInstallPrefix/bin"
Copy-Item $_ $DebugInstallPrefix/bin
}
if (-Not $DoNotDeleteBuildFolder) {
Write-Host "Removing folder $debug_build_folder" -ForegroundColor Yellow
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue $debug_build_folder
}
}
$release_build_folder = "$PSCustomScriptRoot/build_release"
if (-Not $DoNotDeleteBuildFolder) {
Expand Down Expand Up @@ -1010,19 +1019,22 @@ else {
if (-Not ($exitCode -eq 0)) {
MyThrow("Build failed! Exited with error code $exitCode.")
}
Remove-Item -Force -ErrorAction SilentlyContinue DarknetConfig.cmake
Remove-Item -Force -ErrorAction SilentlyContinue DarknetConfigVersion.cmake
if (-Not $UseVCPKG -And -Not $DisableDLLcopy) {
$dllfiles = Get-ChildItem ./${dllfolder}/*.dll
if ($dllfiles) {
Copy-Item $dllfiles ..
}
}
if (-Not $DoNotDeleteBuildFolder) {
Write-Host "Removing folder $release_build_folder" -ForegroundColor Yellow
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue $release_build_folder
if ($BuildInstaller) {
Write-Host "Building package with CPack" -ForegroundColor Green
$proc = Start-Process -NoNewWindow -PassThru -FilePath $CMAKE_EXE -ArgumentList "--build . --target package"
$handle = $proc.Handle
$proc.WaitForExit()
$exitCode = $proc.ExitCode
if (-Not ($exitCode -eq 0)) {
MyThrow("Packaging failed! Exited with error code $exitCode.")
}
}
Set-Location ..
}

Pop-Location
Expand Down
3 changes: 1 addition & 2 deletions src/art.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ void demo_art(char *cfgfile, char *weightfile, int cam_index)

float *p = network_predict(net, in_s.data);

printf("\033[2J");
printf("\033[1;1H");
printf("\033[H\033[J");

float score = 0;
for(i = 0; i < n; ++i){
Expand Down
16 changes: 4 additions & 12 deletions src/classifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,11 +1129,8 @@ void threat_classifier(char *datacfg, char *cfgfile, char *weightfile, int cam_i
sprintf(buff, "tmp/threat_%06d", count);
//save_image(out, buff);

#ifndef _WIN32
printf("\033[2J");
printf("\033[1;1H");
#endif
printf("\nFPS:%.0f\n",fps);
printf("\033[H\033[J");
printf("\nFPS:%.0f\n", fps);

for(i = 0; i < top; ++i){
int index = indexes[i];
Expand Down Expand Up @@ -1208,8 +1205,7 @@ void gun_classifier(char *datacfg, char *cfgfile, char *weightfile, int cam_inde
float *predictions = network_predict(net, in_s.data);
top_predictions(net, top, indexes);

printf("\033[2J");
printf("\033[1;1H");
printf("\033[H\033[J");

int threat = 0;
for(i = 0; i < sizeof(bad_cats)/sizeof(bad_cats[0]); ++i){
Expand Down Expand Up @@ -1308,11 +1304,7 @@ void demo_classifier(char *datacfg, char *cfgfile, char *weightfile, int cam_ind
if(net.hierarchy) hierarchy_predictions(predictions, net.outputs, net.hierarchy, 1);
top_predictions(net, top, indexes);

#ifndef _WIN32
printf("\033[2J");
printf("\033[1;1H");
#endif

printf("\033[H\033[J");

if (!benchmark) {
printf("\rFPS: %.2f (use -benchmark command line flag for correct measurement)\n", fps);
Expand Down
Binary file added src/darknet.ico
Binary file not shown.
1 change: 1 addition & 0 deletions src/darknet.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 ICON "darknet.ico"
3 changes: 1 addition & 2 deletions src/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@ void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int

if (l.embedding_size) set_track_id(local_dets, local_nboxes, demo_thresh, l.sim_thresh, l.track_ciou_norm, l.track_history_size, l.dets_for_track, l.dets_for_show);

//printf("\033[2J");
//printf("\033[1;1H");
printf("\033[H\033[J");
//printf("\nFPS:%.1f\n", fps);
printf("Objects:\n\n");

Expand Down
7 changes: 3 additions & 4 deletions src/detector.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,13 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
if (mean_average_precision > 0) printf("\n Last accuracy mAP@%0.2f = %2.2f %%, best = %2.2f %% ", iou_thresh, mean_average_precision * 100, best_map * 100);
}

#ifndef WIN32
printf("\033[H\033[J");
if (mean_average_precision > 0.0) {
printf("\033]2;%d/%d: loss=%0.1f map=%0.2f best=%0.2f hours left=%0.1f\007", iteration, net.max_batches, loss, mean_average_precision, best_map, avg_time);
printf("%d/%d: loss=%0.1f map=%0.2f best=%0.2f hours left=%0.1f\007", iteration, net.max_batches, loss, mean_average_precision, best_map, avg_time);
}
else {
printf("\033]2;%d/%d: loss=%0.1f hours left=%0.1f\007", iteration, net.max_batches, loss, avg_time);
printf("%d/%d: loss=%0.1f hours left=%0.1f\007", iteration, net.max_batches, loss, avg_time);
}
#endif

if (net.cudnn_half) {
if (iteration < net.burn_in * 3) fprintf(stderr, "\n Tensor Cores are disabled until the first %d iterations are reached.\n", 3 * net.burn_in);
Expand Down

0 comments on commit 9b095f7

Please sign in to comment.