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');
Download scripts/to_fp16.py from wonfy/BiRefNet-ONNX-webgpu: direct link, hf CLI and curl.
- Browser
- Download file 562 Bytes
-
https://huggingface.co/wonfy/BiRefNet-ONNX-webgpu/resolve/main/scripts/to_fp16.py
- Command line
-
hf download hf://wonfy/BiRefNet-ONNX-webgpu/scripts/to_fp16.py
-
curl -L -o to_fp16.py https://huggingface.co/wonfy/BiRefNet-ONNX-webgpu/resolve/main/scripts/to_fp16.py
562 Bytes
| 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") | |