Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ChineseCLIP models #455

Merged
merged 5 commits into from
Dec 13, 2023
Merged

Add support for ChineseCLIP models #455

merged 5 commits into from
Dec 13, 2023

Conversation

xenova
Copy link
Collaborator

@xenova xenova commented Dec 13, 2023

Usage

import { pipeline } from '@xenova/transformers';

// Create zero-shot image classification pipeline
const classifier = await pipeline('zero-shot-image-classification', 'Xenova/chinese-clip-vit-base-patch16');

// Set image url and candidate labels
const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/pikachu.png';
const candidate_labels = ['杰尼龟', '妙蛙种子', '小火龙', '皮卡丘'] // Squirtle, Bulbasaur, Charmander, Pikachu in Chinese

// Classify image
const output = await classifier(url, candidate_labels);
console.log(output);
// [
//   { score: 0.9926728010177612, label: '皮卡丘' },        // Pikachu
//   { score: 0.003480620216578245, label: '妙蛙种子' },    // Bulbasaur
//   { score: 0.001942147733643651, label: '杰尼龟' },      // Squirtle
//   { score: 0.0019044597866013646, label: '小火龙' }      // Charmander
// ]

@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 2de085b into main Dec 13, 2023
4 checks passed
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.

2 participants