Xenova HF staff commited on
Commit
d5305db
·
verified ·
1 Parent(s): 470d67c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +32 -0
README.md CHANGED
@@ -5,4 +5,36 @@ base_model: jmtzt/ijepa_vith16_1k
5
 
6
  https://huggingface.co/jmtzt/ijepa_vith16_1k with ONNX weights to be compatible with Transformers.js.
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using [🤗 Optimum](https://huggingface.co/docs/optimum/index) and structuring your repo like this one (with ONNX weights located in a subfolder named `onnx`).
 
5
 
6
  https://huggingface.co/jmtzt/ijepa_vith16_1k with ONNX weights to be compatible with Transformers.js.
7
 
8
+ ## Usage (Transformers.js)
9
+
10
+ If you haven't already, you can install the [Transformers.js](https://huggingface.co/docs/transformers.js) JavaScript library from [NPM](https://www.npmjs.com/package/@huggingface/transformers) using:
11
+ ```bash
12
+ npm i @huggingface/transformers
13
+ ```
14
+
15
+ **Example:** Image feature extraction with `onnx-community/ijepa_vith16_1k`.
16
+
17
+ ```js
18
+ import { pipeline, cos_sim } from "@huggingface/transformers";
19
+
20
+ // Create an image feature extraction pipeline
21
+ const extractor = await pipeline(
22
+ "image-feature-extraction",
23
+ "onnx-community/ijepa_vith16_1k",
24
+ { dtype: "q8" },
25
+ );
26
+
27
+ // Compute image embeddings
28
+ const url_1 = "http://images.cocodataset.org/val2017/000000039769.jpg"
29
+ const url_2 = "http://images.cocodataset.org/val2017/000000219578.jpg"
30
+ const output = await extractor([url_1, url_2]);
31
+ const pooled_output = output.mean(1); // Apply mean pooling
32
+
33
+ // Compute cosine similarity
34
+ const similarity = cos_sim(pooled_output[0].data, pooled_output[1].data);
35
+ console.log(similarity); // 0.5334921616321957
36
+ ```
37
+
38
+ ---
39
+
40
  Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using [🤗 Optimum](https://huggingface.co/docs/optimum/index) and structuring your repo like this one (with ONNX weights located in a subfolder named `onnx`).