Commit
·
f9584bd
1
Parent(s):
b305b72
Add acknowledgement section.
Browse files
README.md
CHANGED
|
@@ -34,24 +34,25 @@ from torchvision import transforms
|
|
| 34 |
from models.birefnet import BiRefNet
|
| 35 |
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
# Input Data
|
| 38 |
transform_image = transforms.Compose([
|
| 39 |
transforms.Resize((1024, 1024)),
|
| 40 |
transforms.ToTensor(),
|
| 41 |
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
|
| 42 |
])
|
|
|
|
| 43 |
imagepath = 'PATH-TO-YOUR_IMAGE.jpg'
|
| 44 |
image = Image.open(imagepath)
|
| 45 |
input_images = transform_image(image).unsqueeze(0).to('cuda')
|
| 46 |
|
| 47 |
-
# Load Model
|
| 48 |
-
device = 'cuda'
|
| 49 |
-
torch.set_float32_matmul_precision(['high', 'highest'][0])
|
| 50 |
-
model = BiRefNet.from_pretrained('zhengpeng7/birefnet')
|
| 51 |
-
model.to(device)
|
| 52 |
-
model.eval()
|
| 53 |
-
print('BiRefNet is ready to use.')
|
| 54 |
-
|
| 55 |
# Prediction
|
| 56 |
with torch.no_grad():
|
| 57 |
preds = model(input_images)[-1].sigmoid().cpu()
|
|
@@ -81,6 +82,12 @@ Go to my GitHub page for BiRefNet codes and the latest updates: https://github.c
|
|
| 81 |
+ **Online Inference with GUI on Hugging Face** with adjustable resolutions: [](https://huggingface.co/spaces/ZhengPeng7/BiRefNet_demo)
|
| 82 |
<img src="https://drive.google.com/thumbnail?id=12XmDhKtO1o2fEvBu4OE4ULVB2BK0ecWi&sz=w1080" />
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
## Citation
|
| 85 |
|
| 86 |
```
|
|
|
|
| 34 |
from models.birefnet import BiRefNet
|
| 35 |
|
| 36 |
|
| 37 |
+
# Load Model
|
| 38 |
+
device = 'cuda'
|
| 39 |
+
torch.set_float32_matmul_precision(['high', 'highest'][0])
|
| 40 |
+
model = BiRefNet.from_pretrained('zhengpeng7/birefnet')
|
| 41 |
+
model.to(device)
|
| 42 |
+
model.eval()
|
| 43 |
+
print('BiRefNet is ready to use.')
|
| 44 |
+
|
| 45 |
# Input Data
|
| 46 |
transform_image = transforms.Compose([
|
| 47 |
transforms.Resize((1024, 1024)),
|
| 48 |
transforms.ToTensor(),
|
| 49 |
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
|
| 50 |
])
|
| 51 |
+
|
| 52 |
imagepath = 'PATH-TO-YOUR_IMAGE.jpg'
|
| 53 |
image = Image.open(imagepath)
|
| 54 |
input_images = transform_image(image).unsqueeze(0).to('cuda')
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
# Prediction
|
| 57 |
with torch.no_grad():
|
| 58 |
preds = model(input_images)[-1].sigmoid().cpu()
|
|
|
|
| 82 |
+ **Online Inference with GUI on Hugging Face** with adjustable resolutions: [](https://huggingface.co/spaces/ZhengPeng7/BiRefNet_demo)
|
| 83 |
<img src="https://drive.google.com/thumbnail?id=12XmDhKtO1o2fEvBu4OE4ULVB2BK0ecWi&sz=w1080" />
|
| 84 |
|
| 85 |
+
## Acknowledgement:
|
| 86 |
+
|
| 87 |
+
+ Many thanks to @fal for their generous support on GPU resources for training better BiRefNet models.
|
| 88 |
+
+ Many thanks to @not-lain for his help on the better deployment of our BiRefNet model on Huggingface.
|
| 89 |
+
|
| 90 |
+
|
| 91 |
## Citation
|
| 92 |
|
| 93 |
```
|