Skip to content

Commit 07b83fb

Browse files
not-lainWauplin
andauthored
Add BiRefNet (huggingface#799)
This PR will add BiRefNet to the list of of recognized libraries on huggingface. cc @Wauplin for review --------- Co-authored-by: Lucain <[email protected]>
1 parent 6924e5f commit 07b83fb

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/tasks/src/model-libraries-snippets.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,20 @@ wavs = chat.infer(texts, )
732732
torchaudio.save("output1.wav", torch.from_numpy(wavs[0]), 24000)`,
733733
];
734734

735+
export const birefnet = (model: ModelData): string[] => [
736+
`# Option 1: use with transformers
737+
738+
from transformers import AutoModelForImageSegmentation
739+
birefnet = AutoModelForImageSegmentation.from_pretrained("${model.id}", trust_remote_code=True)
740+
`,
741+
`# Option 2: use with BiRefNet
742+
743+
# Install from https://github.com/ZhengPeng7/BiRefNet
744+
745+
from models.birefnet import BiRefNet
746+
model = BiRefNet.from_pretrained("${model.id}")`,
747+
];
748+
735749
export const mlx = (model: ModelData): string[] => [
736750
`pip install huggingface_hub hf_transfer
737751

packages/tasks/src/model-libraries.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
114114
filter: false,
115115
countDownloads: `path_extension:"npz"`,
116116
},
117+
birefnet: {
118+
prettyLabel: "BiRefNet",
119+
repoName: "BiRefNet",
120+
repoUrl: "https://github.com/ZhengPeng7/BiRefNet",
121+
snippets: snippets.birefnet,
122+
filter: false,
123+
},
117124
bm25s: {
118125
prettyLabel: "BM25S",
119126
repoName: "bm25s",

0 commit comments

Comments
 (0)