55
55
clip_ctx_p = NewType ("clip_ctx_p" , int )
56
56
clip_ctx_p_ctypes = c_void_p
57
57
58
+ # struct clip_image_u8;
59
+ clip_image_u8_p = NewType ("clip_image_u8_p" , int )
60
+ clip_image_u8_p_ctypes = c_void_p
61
+
58
62
59
63
# struct llava_image_embed {
60
64
# float * embed;
@@ -79,19 +83,35 @@ def llava_validate_embed_size(
79
83
) -> bool :
80
84
...
81
85
86
+ # LLAVA_API bool llava_image_embed_make_with_clip_img(struct clip_ctx * ctx_clip, int n_threads, const struct clip_image_u8 * img, float ** image_embd_out, int * n_img_pos_out);
87
+ @ctypes_function (
88
+ "llava_image_embed_make_with_clip_img" ,
89
+ [clip_ctx_p_ctypes , c_int , clip_image_u8_p_ctypes , POINTER (POINTER (c_float )), POINTER (c_int )],
90
+ c_bool
91
+ )
92
+ def llava_image_embed_make_with_clip_img (
93
+ ctx_clip : clip_ctx_p ,
94
+ n_threads : int ,
95
+ img : clip_image_u8_p ,
96
+ image_embd_out : _Pointer [_Pointer [c_float ]],
97
+ n_img_pos_out : _Pointer [c_int ],
98
+ / ,
99
+ ) -> bool :
100
+ ...
101
+
82
102
83
103
# /** build an image embed from image file bytes */
84
104
# LLAVA_API struct llava_image_embed * llava_image_embed_make_with_bytes(struct clip_ctx * ctx_clip, int n_threads, const unsigned char * image_bytes, int image_bytes_length);
85
105
@ctypes_function (
86
106
"llava_image_embed_make_with_bytes" ,
87
- [clip_ctx_p_ctypes , c_int , POINTER ( c_uint8 ) , c_int ],
107
+ [clip_ctx_p_ctypes , c_int , c_char_p , c_int ],
88
108
POINTER (llava_image_embed ),
89
109
)
90
110
def llava_image_embed_make_with_bytes (
91
111
ctx_clip : clip_ctx_p ,
92
- n_threads : Union [ c_int , int ] ,
93
- image_bytes : CtypesArray [ c_uint8 ] ,
94
- image_bytes_length : Union [ c_int , int ] ,
112
+ n_threads : c_int ,
113
+ image_bytes : c_char_p ,
114
+ image_bytes_length : c_int ,
95
115
/ ,
96
116
) -> "_Pointer[llava_image_embed]" :
97
117
...
@@ -105,7 +125,7 @@ def llava_image_embed_make_with_bytes(
105
125
POINTER (llava_image_embed ),
106
126
)
107
127
def llava_image_embed_make_with_filename (
108
- ctx_clip : clip_ctx_p , n_threads : Union [ c_int , int ], image_path : bytes , /
128
+ ctx_clip : clip_ctx_p , n_threads : c_int , image_path : c_char_p , /
109
129
) -> "_Pointer[llava_image_embed]" :
110
130
...
111
131
@@ -143,18 +163,14 @@ def llava_eval_image_embed(
143
163
# clip.h
144
164
################################################
145
165
146
- # struct clip_image_f32;
147
- clip_image_f32_p = NewType ("clip_image_f32_p" , int )
148
- clip_image_f32_p_ctypes = c_void_p
149
-
150
- # struct clip_image_u8;
151
- clip_image_u8_p = NewType ("clip_image_u8_p" , int )
152
- clip_image_u8_p_ctypes = c_void_p
153
-
154
166
# struct clip_image_u8_batch;
155
167
clip_image_u8_batch_p = NewType ("clip_image_u8_batch_p" , int )
156
168
clip_image_u8_batch_p_ctypes = c_void_p
157
169
170
+ # struct clip_image_f32;
171
+ clip_image_f32_p = NewType ("clip_image_f32_p" , int )
172
+ clip_image_f32_p_ctypes = c_void_p
173
+
158
174
# struct clip_image_f32_batch;
159
175
clip_image_f32_batch_p = NewType ("clip_image_f32_batch_p" , int )
160
176
clip_image_f32_batch_p_ctypes = c_void_p
@@ -449,7 +465,7 @@ def clip_image_encode(
449
465
ctx : clip_ctx_p ,
450
466
n_threads : int ,
451
467
img : clip_image_f32_p ,
452
- vec : POINTER ( c_float ) , /
468
+ vec : _Pointer [ c_float ] , /
453
469
) -> bool :
454
470
...
455
471
@@ -459,7 +475,7 @@ def clip_image_batch_encode(
459
475
ctx : clip_ctx_p ,
460
476
n_threads : int ,
461
477
imgs : clip_image_f32_batch_p ,
462
- vec : POINTER ( c_float ) , /
478
+ vec : _Pointer [ c_float ] , /
463
479
) -> bool :
464
480
...
465
481
@@ -502,9 +518,9 @@ def clip_is_gemma3(ctx: clip_ctx_p) -> bool:
502
518
def clip_n_output_tokens (
503
519
ctx : clip_ctx_p ,
504
520
n_threads : int ,
505
- img : POINTER ( float ) ,
521
+ img : _Pointer [ float ] ,
506
522
h : int ,
507
523
w : int ,
508
- vec : POINTER ( float ) ,/
524
+ vec : _Pointer [ float ] ,/
509
525
) -> bool :
510
526
...
0 commit comments