Skip to content

Conversation

@xenova
Copy link
Collaborator

@xenova xenova commented Dec 5, 2024

Example usage:

import { pipeline, cos_sim } from "@huggingface/transformers";

// Create an image feature extraction pipeline
const extractor = await pipeline(
  "image-feature-extraction",
  "onnx-community/ijepa_vith16_1k",
  { dtype: "q8" },
);

// Compute image embeddings
const url_1 = "http://images.cocodataset.org/val2017/000000039769.jpg"
const url_2 = "http://images.cocodataset.org/val2017/000000219578.jpg"
const output = await extractor([url_1, url_2]);
const pooled_output = output.mean(1); // Apply mean pooling

// Compute cosine similarity
const similarity = cos_sim(pooled_output[0].data, pooled_output[1].data);
console.log(similarity); // 0.5334921616321957

Supported models: https://huggingface.co/models?library=transformers.js&other=ijepa&sort=trending

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@xenova xenova merged commit e4dac8a into main Dec 6, 2024
4 checks passed
@xenova xenova deleted the add-ijepa branch December 6, 2024 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants