Views
No views yet
BritishWerewolf/IS-Net.1import { AutoModel, AutoProcessor, RawImage } from '@huggingface/transformers';
2
3const img_url = 'https://huggingface.co/ybelkada/segment-anything/resolve/main/assets/car.png';
4const image = await RawImage.read(img_url);
5
6const processor = await AutoProcessor.from_pretrained('BritishWerewolf/IS-Net');
7const processed = await processor(image);
8
9const model = await AutoModel.from_pretrained('BritishWerewolf/IS-Net', {
10 dtype: 'fp32',
11});
12
13const output = await model({ input: processed.pixel_values });
14// {
15// mask: Tensor {
16// dims: [ 1, 1024, 1024 ],
17// type: 'uint8',
18// data: Uint8Array(1048576) [ ... ],
19// size: 1048576
20// }
21// }AutoProcessor and AutoModel classes from the transformers library make it easy to load the model and processor.rembg for the ONNX model.