|
Download README.md from Jia-Liu/U2Net-CoreML: direct link, hf CLI and curl.
- Browser
- Download file 2.45 kB
-
https://huggingface.co/Jia-Liu/U2Net-CoreML/resolve/main/README.md
- Command line
-
hf download hf://Jia-Liu/U2Net-CoreML/README.md
-
curl -L -o README.md https://huggingface.co/Jia-Liu/U2Net-CoreML/resolve/main/README.md
2.45 kB
metadata
license: apache-2.0
language: en
tags:
- coreml
- u2net
- image-segmentation
- salient-object-detection
- macos
U-2-Net (U2NET) - Core ML Format
U-2-Net model converted to Apple Core ML format for macOS GPU-accelerated inference.
π Original Model
- Source Repository: https://github.com/xuebinqin/U-2-Net
- License: Apache 2.0
- Paper: UΒ²-Net: Going Deeper with Nested U-Structure for Salient Object Detection
- Authors: Xuebin Qin, Zichen Zhang, Chenyang Huang, Masood Dehghan, Osmar R. ZaΓ―ane, Martin Jagersand
π Conversion Details
This model was converted from PyTorch to Core ML format using the following method:
- Conversion Method:
torch.jit.traceβcoremltools.convert() - Input Shape:
(1, 3, 320, 320)RGB image - Precision: FP32
- Compute Units: CPU + GPU
- Output Format: Core ML Package (
.mlpackage)
Conversion Script
import torch
import coremltools as ct
from u2net import U2NET
# Load model
u2net = U2NET(3, 1)
u2net.load_state_dict(torch.load("u2net.pth", map_location="cpu"))
u2net.eval()
# Trace and convert
dummy = torch.randn(1, 3, 320, 320)
traced = torch.jit.trace(u2net, dummy)
coreml_model = ct.convert(traced, inputs=[ct.ImageType(shape=(1, 3, 320, 320))])
coreml_model.save("U2NET.mlpackage")
π₯ Usage
Load the model in a macOS application using Core ML:
import CoreML
import Vision
let config = MLModelConfiguration()
config.computeUnits = .cpuAndGPU
let model = try U2NET(configuration: config)
π Model Inputs/Outputs
Input:
image: 3-channel RGB image, 320Γ320 pixels
Outputs (7 saliency maps at different scales):
- 7 output tensors, each 1-channel, 320Γ320
βοΈ License & Attribution
This repository contains a format conversion of the original U-2-Net model. All rights and credit belong to the original authors.
- Original License: Apache 2.0
- Conversion: Format-only, no weight modifications
π Citation
If you use this model, please cite the original paper:
@article{qin2020u2net,
title={U$^2$-Net: Going Deeper with Nested U-Structure for Salient Object Detection},
author={Qin, Xuebin and Zhang, Zichen and Huang, Chenyang and Dehghan, Masood and Zaiane, Osmar R and Jagersand, Martin},
journal={Pattern Recognition},
volume={106},
pages={107404},
year={2020},
publisher={Elsevier}
}