Xenova Profile picture
Bringing the power of machine learning to the web. Currently working on Transformers.js (@huggingface 🤗)
Nov 21, 2023 5 tweets 2 min read
Transformers.js v2.9.0 is now out! 😍 New features:
🎯 Zero-shot Object Detection w/ OwlViT
🕵️‍♂️ Depth Estimation w/ DPT and GLPN
📝 Optical Document Understanding w/ Nougat

... and you can get started in just a few lines of code! 🤯👇
Example output of the "Zero-shot object detection" task. The image is of an astronaut, with several objects (including an American flag, a model rocket, and a helmet) in the scene. Red bounding boxes, which were generated using a vision transformer model, surround the objects. 1. Zero-shot Object Detection is the task of identifying objects of classes that are unseen during training.

This means you can specify a list of words/phrases at runtime, and the model will generate bounding boxes for any occurrences it finds!

Example code: // npm i @xenova/transformers import { pipeline } from '@xenova/transformers';  // Create zero-shot object detection pipeline let detector = await pipeline('zero-shot-object-detection', 'Xenova/owlvit-base-patch32');  // Predict bounding boxes let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/astronaut.png'; let candidate_labels = ['human face', 'rocket', 'helmet', 'american flag']; let output = await detector(url, candidate_labels);