@coreviz/sdk 1.0.6 → 1.0.7
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 -14
- package/package.json +1 -1
package/dist/coreviz.js
CHANGED
|
@@ -174,27 +174,16 @@ 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
|
|
189
182
|
const tokenizer = await AutoTokenizer.from_pretrained(MODEL_ID);
|
|
190
183
|
const processor = await AutoProcessor.from_pretrained(MODEL_ID);
|
|
191
184
|
// Load models with device preference
|
|
192
|
-
const text_model = await CLIPTextModelWithProjection.from_pretrained(MODEL_ID
|
|
193
|
-
|
|
194
|
-
});
|
|
195
|
-
const vision_model = await CLIPVisionModelWithProjection.from_pretrained(MODEL_ID, {
|
|
196
|
-
device: device,
|
|
197
|
-
});
|
|
185
|
+
const text_model = await CLIPTextModelWithProjection.from_pretrained(MODEL_ID);
|
|
186
|
+
const vision_model = await CLIPVisionModelWithProjection.from_pretrained(MODEL_ID);
|
|
198
187
|
console.log(`Model loaded in ${Date.now() - start}ms`);
|
|
199
188
|
// Check if input is likely an image
|
|
200
189
|
const isImage = options?.type === 'image' ||
|