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/fold.py from wonfy/BiRefNet-ONNX-webgpu: direct link, hf CLI and curl.
- Browser
- Download file 403 Bytes
-
https://huggingface.co/wonfy/BiRefNet-ONNX-webgpu/resolve/main/scripts/fold.py
- Command line
-
hf download hf://wonfy/BiRefNet-ONNX-webgpu/scripts/fold.py
-
curl -L -o fold.py https://huggingface.co/wonfy/BiRefNet-ONNX-webgpu/resolve/main/scripts/fold.py
403 Bytes
| import sys | |
| import time | |
| import onnxruntime as ort | |
| source, target = sys.argv[1], sys.argv[2] | |
| options = ort.SessionOptions() | |
| options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_BASIC | |
| options.optimized_model_filepath = target | |
| started = time.time() | |
| ort.InferenceSession(source, options, providers=["CPUExecutionProvider"]) | |
| print(f"folded in {time.time() - started:.1f} s -> {target}") | |