@coreviz/sdk 1.0.6 → 1.0.8
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 +3 -10
- package/package.json +1 -1
package/dist/coreviz.js
CHANGED
|
@@ -174,15 +174,8 @@ class CoreViz {
|
|
|
174
174
|
async embedLocal(input, options) {
|
|
175
175
|
try {
|
|
176
176
|
// Dynamic import to avoid loading transformers if not used
|
|
177
|
-
const { AutoTokenizer, AutoProcessor, CLIPTextModelWithProjection, CLIPVisionModelWithProjection, RawImage
|
|
178
|
-
// Force browser backend to use webgpu if available
|
|
179
|
-
// @ts-ignore
|
|
180
|
-
if (typeof navigator !== 'undefined' && navigator.gpu && env.backends?.onnx?.wasm) {
|
|
181
|
-
// @ts-ignore
|
|
182
|
-
env.backends.onnx.wasm.proxy = false;
|
|
183
|
-
}
|
|
177
|
+
const { AutoTokenizer, AutoProcessor, CLIPTextModelWithProjection, CLIPVisionModelWithProjection, RawImage } = await Promise.resolve().then(() => __importStar(require('@huggingface/transformers')));
|
|
184
178
|
const MODEL_ID = 'Xenova/clip-vit-large-patch14';
|
|
185
|
-
const device = 'webgpu';
|
|
186
179
|
console.log(`Loading local model ${MODEL_ID}...`);
|
|
187
180
|
const start = Date.now();
|
|
188
181
|
// Load tokenizer and processor
|
|
@@ -190,10 +183,10 @@ class CoreViz {
|
|
|
190
183
|
const processor = await AutoProcessor.from_pretrained(MODEL_ID);
|
|
191
184
|
// Load models with device preference
|
|
192
185
|
const text_model = await CLIPTextModelWithProjection.from_pretrained(MODEL_ID, {
|
|
193
|
-
|
|
186
|
+
dtype: 'q4',
|
|
194
187
|
});
|
|
195
188
|
const vision_model = await CLIPVisionModelWithProjection.from_pretrained(MODEL_ID, {
|
|
196
|
-
|
|
189
|
+
dtype: 'q4',
|
|
197
190
|
});
|
|
198
191
|
console.log(`Model loaded in ${Date.now() - start}ms`);
|
|
199
192
|
// Check if input is likely an image
|