feat(demo): Add --help, fix run_demo.bat path, add iostream to classifier

- Add --help/-h CLI option to demo_offline with usage description
- Fix run_demo.bat validation dataset path: dataset\val -> dataset\binary\val
- Add missing #include <iostream> to gunshot_classifier.cpp for error messages
- All tests pass: test_core_lib 9/9, demo_offline 20/20
zhaochang_branch
赵昌 20 hours ago
parent 31e2470090
commit e451d75ab5

@ -8,7 +8,7 @@ echo ==========================================
set BUILD_DIR=%~dp0build
set MODEL=models\gunshot_classifier.onnx
set VAL_DIR=dataset\val
set VAL_DIR=dataset\binary\val
REM --- Ensure executables exist ---
if not exist "%BUILD_DIR%\test_core_lib.exe" (

@ -2,6 +2,7 @@
#include <cmath>
#include <fstream>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <memory>

@ -27,6 +27,9 @@ struct Prediction {
void print_usage(const char* prog) {
std::cerr << "Usage: " << prog << " <file_or_dir> [--model <onnx>] [--label_map <json>] [--threshold <float>]" << std::endl;
std::cerr << " --model <path> ONNX model path (default: models/gunshot_classifier.onnx)" << std::endl;
std::cerr << " --label_map <path> Label map file (default: models/label_map.json)" << std::endl;
std::cerr << " --threshold <float> Detection threshold (default: 0.5)" << std::endl;
}
bool ends_with(const std::string& s, const std::string& suffix) {
@ -181,9 +184,9 @@ void print_report(const std::vector<Prediction>& results) {
}
int main(int argc, char** argv) {
if (argc < 2) {
if (argc < 2 || std::strcmp(argv[1], "--help") == 0 || std::strcmp(argv[1], "-h") == 0) {
print_usage(argv[0]);
return 1;
return argc < 2 ? 1 : 0;
}
std::string target = argv[1];

Loading…
Cancel
Save