Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
---
|
4 |
+
|
5 |
+
# Torch Scripts
|
6 |
+
|
7 |
+
## VitMatte
|
8 |
+
The demo files are [here](https://github.com/hustvl/ViTMatte/tree/main/demo)
|
9 |
+
```python
|
10 |
+
import torch
|
11 |
+
|
12 |
+
image = Image.open("./retriever_rgb.png").convert("RGB")
|
13 |
+
image = F.to_tensor(image).unsqueeze(0).to("cuda").half()
|
14 |
+
|
15 |
+
trimap = Image.open("./retriever_trimap.png").convert("L")
|
16 |
+
trimap = F.to_tensor(trimap).unsqueeze(0).to("cuda").half()
|
17 |
+
|
18 |
+
input = {"image": image, "trimap": trimap}
|
19 |
+
|
20 |
+
model = torch.jit.load("./vitmatte_b_dis.pt").to("cuda")
|
21 |
+
alpha = model(input)
|
22 |
+
|
23 |
+
output = F.to_pil_image(predictions)
|
24 |
+
output.save("./predicted.png")
|
25 |
+
```
|