MCPcopy Create free account
hub / github.com/PABannier/sam3.cpp / main

Function main

tests/test_sam2_backbone_compare.cpp:11–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include <sys/stat.h>
10
11int main(int argc, char** argv) {
12 if (argc < 4) {
13 fprintf(stderr, "Usage: %s <model.ggml> <preprocessed.bin> <output_dir>\n", argv[0]);
14 return 1;
15 }
16
17 mkdir(argv[3], 0755);
18
19 std::ifstream fin(argv[2], std::ios::binary);
20 fin.seekg(0, std::ios::end);
21 size_t sz = fin.tellg();
22 fin.seekg(0);
23 std::vector<float> img(sz / 4);
24 fin.read(reinterpret_cast<char*>(img.data()), sz);
25
26 sam3_params p;
27 p.model_path = argv[1];
28 p.n_threads = 8;
29 p.use_gpu = false;
30 auto model = sam3_load_model(p);
31 if (!model) return 1;
32 auto state = sam3_create_state(*model, p);
33 if (!state) return 1;
34
35 if (!sam3_encode_image_from_preprocessed(*state, *model, img.data(), 1024)) return 1;
36
37 // Dump FPN outputs via state tensor API
38 for (int i = 0; i < 3; ++i) {
39 char name[32];
40 snprintf(name, sizeof(name), "neck_trk_%d", i);
41 std::string path = std::string(argv[3]) + "/" + name;
42 sam3_dump_state_tensor(*state, name, path);
43 }
44
45 fprintf(stderr, "Done.\n");
46 return 0;
47}

Callers

nothing calls this directly

Calls 4

sam3_load_modelFunction · 0.85
sam3_create_stateFunction · 0.85
sam3_dump_state_tensorFunction · 0.85

Tested by

no test coverage detected