@coreviz/sdk 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/coreviz.js +6 -4
- package/package.json +1 -1
package/dist/coreviz.js
CHANGED
|
@@ -176,15 +176,17 @@ class CoreViz {
|
|
|
176
176
|
// Dynamic import to avoid loading transformers if not used
|
|
177
177
|
const { AutoTokenizer, AutoProcessor, CLIPTextModelWithProjection, CLIPVisionModelWithProjection, RawImage } = await Promise.resolve().then(() => __importStar(require('@huggingface/transformers')));
|
|
178
178
|
const MODEL_ID = 'Xenova/clip-vit-large-patch14';
|
|
179
|
-
console.log(`Loading local model ${MODEL_ID}...`);
|
|
180
179
|
const start = Date.now();
|
|
181
180
|
// Load tokenizer and processor
|
|
182
181
|
const tokenizer = await AutoTokenizer.from_pretrained(MODEL_ID);
|
|
183
182
|
const processor = await AutoProcessor.from_pretrained(MODEL_ID);
|
|
184
183
|
// Load models with device preference
|
|
185
|
-
const text_model = await CLIPTextModelWithProjection.from_pretrained(MODEL_ID
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
const text_model = await CLIPTextModelWithProjection.from_pretrained(MODEL_ID, {
|
|
185
|
+
dtype: 'q4',
|
|
186
|
+
});
|
|
187
|
+
const vision_model = await CLIPVisionModelWithProjection.from_pretrained(MODEL_ID, {
|
|
188
|
+
dtype: 'q4',
|
|
189
|
+
});
|
|
188
190
|
// Check if input is likely an image
|
|
189
191
|
const isImage = options?.type === 'image' ||
|
|
190
192
|
input.startsWith('data:image') ||
|