summaryrefslogtreecommitdiff
path: root/examples/llava/clip.h
diff options
context:
space:
mode:
authorGeorgi Gerganov <ggerganov@gmail.com>2023-12-30 23:24:42 +0200
committerGitHub <noreply@github.com>2023-12-30 23:24:42 +0200
commit9fbda719de18a9400a064c28759c39d55d687d3e (patch)
tree97a341a28bd18ce9619cfb891ccf36a0e8df4a15 /examples/llava/clip.h
parent39d8bc71edcb8b6f99d46fa4216af7a15232e218 (diff)
clip : refactor + bug fixes (#4696)
* clip : refactor + bug fixes ggml-ci * server : add log message
Diffstat (limited to 'examples/llava/clip.h')
-rw-r--r--examples/llava/clip.h48
1 files changed, 16 insertions, 32 deletions
diff --git a/examples/llava/clip.h b/examples/llava/clip.h
index f11df85d..458a256a 100644
--- a/examples/llava/clip.h
+++ b/examples/llava/clip.h
@@ -35,31 +35,14 @@ struct clip_vision_hparams {
float eps;
};
-/** load mmproj model */
-CLIP_API struct clip_ctx * clip_model_load(const char * fname, const int verbosity);
-/** free mmproj model */
+CLIP_API struct clip_ctx * clip_model_load(const char * fname, int verbosity);
+
CLIP_API void clip_free(struct clip_ctx * ctx);
-size_t clip_embd_nbytes(const struct clip_ctx * ctx);
-int clip_n_patches(const struct clip_ctx * ctx);
-int clip_n_mmproj_embd(const struct clip_ctx * ctx);
+CLIP_API size_t clip_embd_nbytes(const struct clip_ctx * ctx);
-// RGB uint8 image
-struct clip_image_u8 {
- int nx;
- int ny;
- uint8_t * data = NULL;
- size_t size;
-};
-
-// RGB float32 image (NHWC)
-// Memory layout: RGBRGBRGB...
-struct clip_image_f32 {
- int nx;
- int ny;
- float * data = NULL;
- size_t size;
-};
+CLIP_API int clip_n_patches (const struct clip_ctx * ctx);
+CLIP_API int clip_n_mmproj_embd(const struct clip_ctx * ctx);
struct clip_image_u8_batch {
struct clip_image_u8 * data;
@@ -71,21 +54,22 @@ struct clip_image_f32_batch {
size_t size;
};
-struct clip_image_u8 * make_clip_image_u8();
-struct clip_image_f32 * make_clip_image_f32();
-CLIP_API void clip_image_u8_free(clip_image_u8 * img);
-CLIP_API void clip_image_f32_free(clip_image_f32 * img);
+CLIP_API struct clip_image_u8 * clip_image_u8_init ();
+CLIP_API struct clip_image_f32 * clip_image_f32_init();
+
+CLIP_API void clip_image_u8_free (struct clip_image_u8 * img);
+CLIP_API void clip_image_f32_free(struct clip_image_f32 * img);
+
CLIP_API bool clip_image_load_from_file(const char * fname, struct clip_image_u8 * img);
+
/** interpret bytes as an image file with length bytes_length, and use the result to populate img */
CLIP_API bool clip_image_load_from_bytes(const unsigned char * bytes, size_t bytes_length, struct clip_image_u8 * img);
-bool clip_image_preprocess(const struct clip_ctx * ctx, const struct clip_image_u8 * img, struct clip_image_f32 * res, const bool pad2square);
-bool clip_image_encode(const struct clip_ctx * ctx, const int n_threads, struct clip_image_f32 * img, float * vec);
-
-bool clip_image_batch_encode(const struct clip_ctx * ctx, const int n_threads, const struct clip_image_f32_batch * imgs,
- float * vec);
+CLIP_API bool clip_image_preprocess (struct clip_ctx * ctx, const struct clip_image_u8 * img, struct clip_image_f32 * res, bool pad2square);
+CLIP_API bool clip_image_encode (struct clip_ctx * ctx, int n_threads, struct clip_image_f32 * img, float * vec);
+CLIP_API bool clip_image_batch_encode(struct clip_ctx * ctx, int n_threads, const struct clip_image_f32_batch * imgs, float * vec);
-bool clip_model_quantize(const char * fname_inp, const char * fname_out, const int itype);
+CLIP_API bool clip_model_quantize(const char * fname_inp, const char * fname_out, int itype);
#ifdef __cplusplus
}