Comments (3)
You can specify model_file_name
as one of the options in .from_pretrained(model_id, { model_file_name: 'model' }
:)
Although, do note that the weights I uploaded only work for Transformers.js v3 (unless you manually override the onnxruntime-web/node version to >= 1.16.0).
See the README for example Transformers.js code:
import { AutoTokenizer, CLIPTextModelWithProjection, AutoProcessor, CLIPVisionModelWithProjection, RawImage, cos_sim } from '@xenova/transformers';
// Load tokenizer and text model
const tokenizer = await AutoTokenizer.from_pretrained('jinaai/jina-clip-v1');
const text_model = await CLIPTextModelWithProjection.from_pretrained('jinaai/jina-clip-v1');
// Load processor and vision model
const processor = await AutoProcessor.from_pretrained('Xenova/clip-vit-base-patch32');
const vision_model = await CLIPVisionModelWithProjection.from_pretrained('jinaai/jina-clip-v1');
// Run tokenization
const texts = ['A blue cat', 'A red cat'];
const text_inputs = tokenizer(texts, { padding: true, truncation: true });
// Compute text embeddings
const { text_embeds } = await text_model(text_inputs);
// Read images and run processor
const urls = [
'https://i.pinimg.com/600x315/21/48/7e/21487e8e0970dd366dafaed6ab25d8d8.jpg',
'https://i.pinimg.com/736x/c9/f2/3e/c9f23e212529f13f19bad5602d84b78b.jpg'
];
const image = await Promise.all(urls.map(url => RawImage.read(url)));
const image_inputs = await processor(image);
// Compute vision embeddings
const { image_embeds } = await vision_model(image_inputs);
// Compute similarities
console.log(cos_sim(text_embeds[0].data, text_embeds[1].data)) // text embedding similarity
console.log(cos_sim(text_embeds[0].data, image_embeds[0].data)) // text-image cross-modal similarity
console.log(cos_sim(text_embeds[0].data, image_embeds[1].data)) // text-image cross-modal similarity
console.log(cos_sim(text_embeds[1].data, image_embeds[0].data)) // text-image cross-modal similarity
console.log(cos_sim(text_embeds[1].data, image_embeds[1].data)) // text-image cross-modal similarity
from transformers.js.
Feel so fuck for the v3 version. Because there is no v3 for nodejs and the new onnx package is only work for v3
from transformers.js.
The code not work at all, and when I try to using optimum-cli to build the onnx model, the optimum not support the nomic-bert type model(nomic-embed-text-v1.5 can be build but the nomic-embed-vision-v1.5 failed)
so there is no way to run the demo code in transformer.js even stable version
If v3 not ready please not release the onnx only for v3
from transformers.js.
Related Issues (20)
- V3 audio transcription: aud.subarray is not a function HOT 8
- range error: array buffer allocation failed <- how to catch this error?
- transformers@latest: Unsupported model IR version: 9, max supported IR version: 8 HOT 1
- Support nomic-ai/nomic-embed-vision-v1.5 HOT 1
- AutoModel.from_pretrained - Which model is loaded HOT 1
- The scripts/convert.py script fails for a few reasons HOT 1
- RAGatouille/Colbert support
- Result is wrong when decoding tokens one by one HOT 1
- How do you delete a downloaded model? HOT 2
- Support for Both Word-Level and Sentence-Level Timestamps in ASR Decoding
- Segmentation fault while converting Bert-base-uncased with README command HOT 2
- Can't run depth-anything-v2 HOT 1
- Support for react-native
- JavaScript code completion model
- [Severe] Memory leak issue under WebGPU Whisper transcribe pipeline
- 4bit ONNX models support HOT 1
- how to retain spiece token markers HOT 2
- No loader is configured for ".node" files
- musicgen example run error on lastest v3
- compat with transformers >= 4.40 and tokenizers >= 0.19 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transformers.js.