MCPcopy Create free account
hub / github.com/cactus-compute/cactus / test_image_embeddings

Function test_image_embeddings

tests/test_embed.cpp:46–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46static bool test_image_embeddings() {
47 std::cout << "\n╔══════════════════════════════════════════╗\n"
48 << "║ IMAGE EMBEDDING TEST ║\n"
49 << "╚══════════════════════════════════════════╝\n";
50
51 if (!g_model_path) {
52 std::cout << "⊘ SKIP │ CACTUS_TEST_MODEL not set\n";
53 return true;
54 }
55
56 std::string image_path = std::string(g_assets_path) + "/test_monkey.png";
57 const size_t buffer_size = 1024 * 1024 * 4;
58 std::vector<float> embeddings(buffer_size / sizeof(float));
59 size_t embedding_dim = 0;
60
61 cactus_model_t model = cactus_init(g_model_path, nullptr, false);
62 if (!model) {
63 std::cout << "⊘ SKIP │ Model doesn't support image embeddings\n";
64 return true;
65 }
66
67 Timer t;
68 int result = cactus_image_embed(model, image_path.c_str(), embeddings.data(), buffer_size, &embedding_dim);
69 double elapsed = t.elapsed_ms();
70
71 cactus_destroy(model);
72
73 if (result == -1) {
74 std::cout << "⊘ SKIP │ Model doesn't support image embeddings\n";
75 return true;
76 }
77
78 std::cout << "├─ Embedding dim: " << embedding_dim << "\n"
79 << "└─ Time: " << std::fixed << std::setprecision(2) << elapsed << "ms" << std::endl;
80
81 return result > 0 && embedding_dim > 0;
82}
83
84static bool test_audio_embeddings() {
85 std::cout << "\n╔══════════════════════════════════════════╗\n"

Callers 1

mainFunction · 0.85

Calls 5

dataMethod · 0.80
elapsed_msMethod · 0.80
cactus_initFunction · 0.50
cactus_image_embedFunction · 0.50
cactus_destroyFunction · 0.50

Tested by

no test coverage detected