Hugging Face + Visual Blocks Custom Components
Visual blocks is an amazing tool from our friends at Google
that allows you to easily create and experiment with machine learning pipelines using a visual interface. This repository contains the source code for custom components that allow you to use Hugging Face client and server models in your Visual Blocks pipelines.
We've created a few nodes supporting different tasks and models following our Tasks definitions.
[!NOTE]
Visual Blocks seems to be mostly working in Chrome. If you are having trouble with the interface, try using Chrome, and please submit an issue to the Visual Blocks team.
Important links:
Table of Contents
How to use the custom components
To start playing with our custom components you need to Add a custom node to your Visual Blocks project. First you need to start a new project https://visualblocks.withgoogle.com/#/edit/new, then click on the "+" button in the bottom left corner to add a new node.
Then input the pre-bundled code from our npm package. You can do this by pasting the following link into the input field and clicking "Submit":
https:
Then you will be able to see three Hugging Face Collections: Client, Server and Common.
Nodes and Examples
Client Nodes
Client nodes are nodes running tranformers pipelines on the client side using Transformers.js library. All Client nodes have an experimental WebGPU and WASM backend support, and models listed in the Xenova profile are supported.
[!NOTE]
WebGPU support on transformers.js is experimental and may not work on all devices, not all models are supported by WebGPU backend yet.
Translation
Translation Node Example
More info:
Token Classification
Token Classification Node Example
More info:
Text Classification
Text Classification Node Example
More info:
Object Detection
Object Detection Node Example
More info:
Image Segmentation
Image Segmentation Node Example
More info:
Image Classification
Image Classification Node Example
More info:
Depth Estimation
Depth Estimation Node Example
More info:
Background Removal
Background Removal Node Example
Server Nodes
Server nodes are nodes running Transformers pipeline tasks using the Hugging Face Serverless API. For a few selected LLM models, it's running using our hosted Text Generation Inference, our fast, optimized inference for LLMs.
[!NOTE]
You can use the Hugging Face Serverless API for free with limited usage, after which you'll be rate limited. If you need more usage, you can create an account at https://huggingface.co/join and get an API token at https://huggingface.co/settings/tokens or log in using the Hugging Face Login node.
For server nodes you have the option to Login using your Hugging Face account to get more usage and access to private models. Using Hugging Face Hub Login
If successful, you can Apikey directly from the Hugging Face Hub Login node.
Text Generation and Chat Completion
Chat Template Text Generation Node Example
More info:
Fill Mask
Fill Mask Node Example
More info:
Image Classification
Image Classification Node Example
More info:
Summarization
Summarization Node Example
More info:
Text Classification
Text Classification Node Example
More info:
Text Generation
Text Generation Node Example
More info:
Text to Image
Text to Image Node Example
More info:
Token Classification
Token Classification Node Example
More info:
Local Development
-
Clone the repository
git clone https://github.com/huggingface/visual-blocks-custom-components.git
cd visual-blocks-custom-components
-
Install the dependencies
npm i
-
Run the development server
npm run dev
-
Visit Google's staging server
-
Click the + in the bottom left corner to add the custom nodes.
-
Paste in the link to the script (http://localhost:8080/index.js) and click "Submit".