MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / main

Function main

external/ggml/examples/sam/sam.cpp:2232–2370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2230
2231
2232int main(int argc, char ** argv) {
2233 ggml_time_init();
2234 const int64_t t_main_start_us = ggml_time_us();
2235
2236 sam_params params;
2237 params.model = "models/sam-vit-b/ggml-model-f16.bin";
2238
2239 sam_model model;
2240 sam_state state;
2241 int64_t t_load_us = 0;
2242
2243 if (sam_params_parse(argc, argv, params) == false) {
2244 return 1;
2245 }
2246
2247 if (params.seed < 0) {
2248 params.seed = time(NULL);
2249 }
2250 fprintf(stderr, "%s: seed = %d\n", __func__, params.seed);
2251
2252 // load the image
2253 sam_image_u8 img0;
2254 if (!sam_image_load_from_file(params.fname_inp, img0)) {
2255 fprintf(stderr, "%s: failed to load image from '%s'\n", __func__, params.fname_inp.c_str());
2256 return 1;
2257 }
2258 fprintf(stderr, "%s: loaded image '%s' (%d x %d)\n", __func__, params.fname_inp.c_str(), img0.nx, img0.ny);
2259
2260 // preprocess to f32
2261 sam_image_f32 img1;
2262 if (!sam_image_preprocess(img0, img1)) {
2263 fprintf(stderr, "%s: failed to preprocess image\n", __func__);
2264 return 1;
2265 }
2266 fprintf(stderr, "%s: preprocessed image (%d x %d)\n", __func__, img1.nx, img1.ny);
2267
2268
2269 // load the model
2270 {
2271 const int64_t t_start_us = ggml_time_us();
2272
2273 if (!sam_model_load(params, model)) {
2274 fprintf(stderr, "%s: failed to load model from '%s'\n", __func__, params.model.c_str());
2275 return 1;
2276 }
2277
2278 t_load_us = ggml_time_us() - t_start_us;
2279 }
2280
2281 {
2282 static size_t buf_size = 256u*1024*1024;
2283
2284 struct ggml_init_params ggml_params = {
2285 /*.mem_size =*/ buf_size,
2286 /*.mem_buffer =*/ NULL,
2287 /*.no_alloc =*/ false,
2288 };
2289

Callers

nothing calls this directly

Calls 15

ggml_time_initFunction · 0.85
ggml_time_usFunction · 0.85
sam_params_parseFunction · 0.85
sam_image_load_from_fileFunction · 0.85
sam_image_preprocessFunction · 0.85
sam_model_loadFunction · 0.85
ggml_initFunction · 0.85
ggml_new_tensor_3dFunction · 0.85
ggml_new_tensor_1dFunction · 0.85
ggml_tensor_overheadFunction · 0.85
ggml_graph_overheadFunction · 0.85
ggml_gallocr_newFunction · 0.85

Tested by

no test coverage detected