Commit
·
17f5dfc
1
Parent(s):
00c694e
Improve the README.
Browse files
README.md
CHANGED
|
@@ -71,13 +71,18 @@ cd BiRefNet
|
|
| 71 |
```
|
| 72 |
|
| 73 |
```python
|
| 74 |
-
#
|
| 75 |
from models.birefnet import BiRefNet
|
| 76 |
|
| 77 |
-
#
|
| 78 |
birefnet = BiRefNet.from_pretrained('zhengpeng7/birefnet')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
-
|
|
|
|
| 81 |
import torch
|
| 82 |
from utils import check_state_dict
|
| 83 |
|
|
@@ -85,7 +90,6 @@ birefnet = BiRefNet(bb_pretrained=False)
|
|
| 85 |
state_dict = torch.load(PATH_TO_WEIGHT, map_location='cpu')
|
| 86 |
state_dict = check_state_dict(state_dict)
|
| 87 |
birefnet.load_state_dict(state_dict)
|
| 88 |
-
|
| 89 |
```
|
| 90 |
|
| 91 |
#### Use the loaded BiRefNet for inference
|
|
|
|
| 71 |
```
|
| 72 |
|
| 73 |
```python
|
| 74 |
+
# Use codes locally
|
| 75 |
from models.birefnet import BiRefNet
|
| 76 |
|
| 77 |
+
# Load weights from Hugging Face Models
|
| 78 |
birefnet = BiRefNet.from_pretrained('zhengpeng7/birefnet')
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
#### Use codes from GitHub + weights from HuggingFace
|
| 82 |
+
> Only use the weights and codes both locally.
|
| 83 |
|
| 84 |
+
```python
|
| 85 |
+
# Use codes and weights locally
|
| 86 |
import torch
|
| 87 |
from utils import check_state_dict
|
| 88 |
|
|
|
|
| 90 |
state_dict = torch.load(PATH_TO_WEIGHT, map_location='cpu')
|
| 91 |
state_dict = check_state_dict(state_dict)
|
| 92 |
birefnet.load_state_dict(state_dict)
|
|
|
|
| 93 |
```
|
| 94 |
|
| 95 |
#### Use the loaded BiRefNet for inference
|