MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / clip_image_load_from_bytes

Function clip_image_load_from_bytes

examples/llava/clip.cpp:712–722  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

710}
711
712bool clip_image_load_from_bytes(const unsigned char * bytes, size_t bytes_length, struct clip_image_u8 * img) {
713 int nx, ny, nc;
714 auto data = stbi_load_from_memory(bytes, bytes_length, &nx, &ny, &nc, 3);
715 if (!data) {
716 fprintf(stderr, "%s: failed to decode image bytes\n", __func__);
717 return false;
718 }
719 build_clip_img_from_data(data, nx, ny, img);
720 stbi_image_free(data);
721 return true;
722}
723
724// normalize: x = (x - mean) / std
725// TODO: implement bicubic interpolation instead of linear.

Callers 1

Calls 4

stbi_load_from_memoryFunction · 0.85
fprintfFunction · 0.85
build_clip_img_from_dataFunction · 0.85
stbi_image_freeFunction · 0.85

Tested by

no test coverage detected