Instructions to use wonfy/BiRefNet-ONNX-webgpu with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use wonfy/BiRefNet-ONNX-webgpu with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('image-segmentation', 'wonfy/BiRefNet-ONNX-webgpu');
File size: 562 Bytes
041c6b2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | import sys
from collections import Counter
import onnx
from onnxconverter_common import float16
source, target = sys.argv[1], sys.argv[2]
model = float16.convert_float_to_float16(onnx.load(source), keep_io_types=True, disable_shape_infer=False)
onnx.checker.check_model(model)
onnx.save(model, target)
graph = model.graph
float_inits = Counter(onnx.TensorProto.DataType.Name(i.data_type) for i in graph.initializer)
print("initializer types", dict(float_inits))
print("casts", sum(1 for n in graph.node if n.op_type == "Cast"), "of", len(graph.node), "nodes")
|