Vanilla Js Object Detector
Upload an image to detect objects
Artificial Intelligence is no longer confined to research labs and large corporations. With Transformers.js, you can run cutting-edge machine learning models right in your browser without the need for a server or backend infrastructure. Whether you're a developer looking to integrate AI into your application or a curious user eager to explore AI capabilities, Transformers.js opens up a world of possibilities.
Transformers.js brings the power of Hugging Face's transformers Python library to the JavaScript ecosystem. It uses ONNX Runtime to run models efficiently in the browser.
To get started, you don't need any prior experience with machine learning or AI.
Using the Web Interface:
For Developers:
Install the package via npm:
npm install @xenova/transformers
Or include it directly in your HTML:
<script src="https://cdn.jsdelivr.net/npm/@xenova/transformers/dist/transformers.min.js"></script>
Now, you can load a model and run inference:
// Load the pipeline for text generation
const { pipeline } = require('@xenova/transformers');
const generator = await pipeline('text-generation', 'gpt2');
// Generate text
const output = await generator('Once upon a time,');
console.log(output);
It's that simple!
Want to experience the magic of AI without writing a single line of code? Here are 10 free AI demos powered by Transformers.js that you can try directly in your browser.
Description: Convert your speech into text using OpenAI's Whisper model.
Use Case: If you need to convert audio recordings, podcasts, or live speech into text effortlessly, Whisper Web offers a seamless solution right in your browser.
Description: Draw sketches and let the AI guess what you've drawn in real-time.
Use Case: Perfect for educators and students, Doodle Dash makes learning about AI and machine learning engaging and entertaining.
Description: Write code in your browser with real-time AI suggestions.
Use Case: Enhance your coding workflow with intelligent code completions, reducing errors and increasing productivity.
Description: Search for images using text queries. All processing happens in your browser.
Use Case: Ideal for developers looking to integrate image search functionality into their applications without compromising user privacy.
Description: Detect objects in images using pure JavaScript, no frameworks needed.
Use Case: Perfect for developers who prefer minimal dependencies and want to understand the fundamentals of object detection.
Description: Translate text between multiple languages using a React web app.
Use Case: Build multilingual applications that cater to a global audience with ease.
Description: Convert text into natural-sounding speech right in your browser.
Use Case: Enhance accessibility or create interactive voice-based applications without relying on external APIs.
Description: Determine the sentiment of text inputs entirely in the browser.
Use Case: Integrate sentiment analysis into your Next.js applications to gauge user feedback or monitor social media sentiment.
Description: Build your own sentiment analysis API using Node.js.
Use Case: Create backend services that analyze text sentiment, useful for customer service bots, feedback systems, and more.
Description: Explore a variety of AI capabilities all in one place.
Use Case: A one-stop-shop to explore and experiment with different AI models and tasks without any setup.
Ready to create your own app? Check out the Transformers.js template on Hugging Face to get started in one click!
Transformers.js supports a wide range of tasks across Natural Language Processing, Vision, Audio, and Multimodal domains.
| Task | Description | Links |
|---|---|---|
| Text Classification | Assign labels or categories to text. | Docs Models |
| Question Answering | Answer questions based on context. | Docs Models |
| Text Generation | Generate text based on a prompt. | Docs Models |
| Translation | Translate text between languages. | Docs Models |
| Summarization | Summarize long texts into concise summaries. | Docs Models |
| Zero-Shot Classification | Classify text into custom labels without additional training. | Docs Models |
...and many more!
| Task | Description | Links |
|---|---|---|
| Image Classification | Assign labels to images. | Docs Models |
| Object Detection | Detect objects within images. | Docs Models |
| Image Segmentation | Segment images into regions. | Docs Models |
| Depth Estimation | Estimate depth from images. | Docs Models |
| Task | Description | Links |
|---|---|---|
| Automatic Speech Recognition | Transcribe speech to text. | Docs Models |
| Audio Classification | Classify audio clips. | Docs Models |
| Text-to-Speech | Convert text into speech audio. | Docs Models |
| Task | Description | Links |
|---|---|---|
| Image-to-Text | Generate text descriptions from images. | Docs Models |
| Zero-Shot Image Classification | Classify images with custom labels without training. | Docs Models |
| Zero-Shot Audio Classification | Classify audio clips with custom labels without training. | Docs Models |
| Document Question Answering | Answer questions based on document images. | Docs Models |
You don't need to be a developer to harness the power of AI. Here's how you can use and even deploy AI applications without writing code.
All the demos listed above are accessible via your browser. Simply click on the demo links and start interacting with AI models instantly.
Hugging Face Spaces is a free platform where you can find and deploy AI applications.
You can deploy AI apps to your own domain for free using platforms like Hugging Face Spaces, Vercel, or GitHub Pages.
https://yourusername.github.io/repository-name.Deploying your AI-powered applications has never been easier. Here are some platforms where you can host your AI apps for free:
Hugging Face Spaces allows you to deploy AI applications effortlessly. It's integrated with GitHub, making it seamless to update your app.
Vercel is a popular platform for deploying frontend applications, including those built with React, Next.js, and more.
GitHub Pages is ideal for hosting static websites directly from your GitHub repository.
Integrating AI into your web application has never been easier. Here's a step-by-step guide to get you started.
If you're using Node.js or a module bundler:
npm install @xenova/transformers
For direct browser usage, include the script:
<script src="https://cdn.jsdelivr.net/npm/@xenova/transformers/dist/transformers.min.js"></script>
Decide what you want your application to do. Visit the Hugging Face Model Hub to find models compatible with Transformers.js.
For example, to perform sentiment analysis:
const { pipeline } = require('@xenova/transformers');
const classifier = await pipeline('sentiment-analysis');
Use the loaded pipeline to process inputs:
const result = await classifier('I love using Transformers.js!');
console.log(result);
// Output: [{ label: 'POSITIVE', score: 0.9998 }]
Transformers.js allows for customization to suit your needs:
Once your application is ready, deploy it and share it with the world! You can host it on platforms like Hugging Face Spaces, Vercel, or GitHub Pages for free.
Transformers.js democratizes access to advanced AI models by bringing them directly into the browser. Whether you're building a personal project, enhancing a web application, or experimenting with AI, Transformers.js provides a powerful and accessible toolset.
Join the Community
Start harnessing the power of AI in your browser today with Transformers.js!
Note: This article is inspired by and incorporates content from the Transformers.js documentation and examples.
Upload an image to detect objects
Generate code completions for your programming snippets
Draw and save quick doodles online
Enter text to generate a response
Generate AI text instantly in your browser
Find images with text queries
Convert typed text into spoken audio
Transcribe audio files to text instantly