nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 55 lines 1.8 kB view raw
1#include <fdeep/fdeep.hpp> 2#include <iostream> 3#include <filesystem> 4#include <vector> 5#include <string> 6 7int main() { 8 std::vector<std::string> model_files; 9 std::string src_dir = std::getenv("SRC_DIR") ? std::getenv("SRC_DIR") : "."; 10 11 // collect *tn.model files except _metadata 12 try { 13 for (const auto& entry : std::filesystem::recursive_directory_iterator(src_dir)) { 14 if (entry.is_regular_file()) { 15 std::string path = entry.path().string(); 16 if (path.find("tn.model") != std::string::npos && path.find("_metadata.") == std::string::npos) { 17 model_files.push_back(path); 18 } 19 } 20 } 21 } catch (const std::exception& e) { 22 std::cerr << "Error scanning directory: " << e.what() << std::endl; 23 return 1; 24 } 25 26 if (model_files.empty()) { 27 std::cout << "No *.tn.model files found in " << src_dir << std::endl; 28 return 1; 29 } 30 31 std::cout << "Found " << model_files.size() << " model files to test" << std::endl; 32 33 int failed_count = 0; 34 for (const auto& model_file : model_files) { 35 std::cout << "Loading: " << model_file << " ... "; 36 std::cout.flush(); 37 38 try { 39 const auto model = fdeep::load_model(model_file); 40 std::cout << "OK" << std::endl; 41 } catch (const std::exception& e) { 42 std::cout << "FAILED: " << e.what() << std::endl; 43 failed_count++; 44 } 45 } 46 47 if (failed_count > 0) { 48 std::cerr << "\n" << failed_count << " out of " << model_files.size() 49 << " models failed to load" << std::endl; 50 return 1; 51 } 52 53 std::cout << "\nAll " << model_files.size() << " models loaded successfully!" << std::endl; 54 return 0; 55}