ZhengPeng7
commited on
Commit
·
a2238f4
1
Parent(s):
1e0fb18
Add inference endpoint feature.
Browse files- README.md +1 -1
- handler.py +3 -3
README.md
CHANGED
@@ -7,7 +7,7 @@ tags:
|
|
7 |
- pytorch_model_hub_mixin
|
8 |
- model_hub_mixin
|
9 |
repo_url: https://github.com/ZhengPeng7/BiRefNet-legacy
|
10 |
-
pipeline_tag: image-
|
11 |
---
|
12 |
<h1 align="center">Bilateral Reference for High-Resolution Dichotomous Image Segmentation</h1>
|
13 |
|
|
|
7 |
- pytorch_model_hub_mixin
|
8 |
- model_hub_mixin
|
9 |
repo_url: https://github.com/ZhengPeng7/BiRefNet-legacy
|
10 |
+
pipeline_tag: image-segmentation
|
11 |
---
|
12 |
<h1 align="center">Bilateral Reference for High-Resolution Dichotomous Image Segmentation</h1>
|
13 |
|
handler.py
CHANGED
@@ -74,8 +74,8 @@ usage_to_weights_file = {
|
|
74 |
'General-legacy': 'BiRefNet-legacy'
|
75 |
}
|
76 |
|
|
|
77 |
usage = 'General'
|
78 |
-
model_repo = '/'.join(('zhengpeng7', usage_to_weights_file[usage]))
|
79 |
|
80 |
# Set resolution
|
81 |
if usage in ['General-Lite-2K']:
|
@@ -87,9 +87,9 @@ else:
|
|
87 |
|
88 |
|
89 |
class EndpointHandler():
|
90 |
-
def __init__(self
|
91 |
self.birefnet = AutoModelForImageSegmentation.from_pretrained(
|
92 |
-
|
93 |
)
|
94 |
self.birefnet.to(device)
|
95 |
self.birefnet.eval()
|
|
|
74 |
'General-legacy': 'BiRefNet-legacy'
|
75 |
}
|
76 |
|
77 |
+
# Choose the version of BiRefNet here.
|
78 |
usage = 'General'
|
|
|
79 |
|
80 |
# Set resolution
|
81 |
if usage in ['General-Lite-2K']:
|
|
|
87 |
|
88 |
|
89 |
class EndpointHandler():
|
90 |
+
def __init__(self):
|
91 |
self.birefnet = AutoModelForImageSegmentation.from_pretrained(
|
92 |
+
'/'.join(('zhengpeng7', usage_to_weights_file[usage])), trust_remote_code=True
|
93 |
)
|
94 |
self.birefnet.to(device)
|
95 |
self.birefnet.eval()
|