Update README.md
Browse files
README.md
CHANGED
|
@@ -1,33 +1,33 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
---
|
| 4 |
-
|
| 5 |
-
This is the Offical weights of ConFiDeNet
|
| 6 |
-
|
| 7 |
-
```python
|
| 8 |
-
from PIL import Image
|
| 9 |
-
import torch
|
| 10 |
-
from transformers import ConFiDeNetForDepthEstimation, ConFiDeNetImageProcessor
|
| 11 |
-
|
| 12 |
-
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 13 |
-
|
| 14 |
-
image = Image.open("<Image Path>").convert("RGB")
|
| 15 |
-
print(image.size)
|
| 16 |
-
# image.save("image.jpg")
|
| 17 |
-
|
| 18 |
-
image_processor = ConFiDeNetImageProcessor.from_pretrained("
|
| 19 |
-
model = ConFiDeNetForDepthEstimation.from_pretrained("
|
| 20 |
-
|
| 21 |
-
inputs = image_processor(images=image, return_tensors="pt").to(device)
|
| 22 |
-
|
| 23 |
-
with torch.no_grad():
|
| 24 |
-
outputs = model(**inputs)
|
| 25 |
-
|
| 26 |
-
post_processed_output = image_processor.post_process_depth_estimation(
|
| 27 |
-
outputs, target_sizes=[(image.height, image.width)],
|
| 28 |
-
)
|
| 29 |
-
|
| 30 |
-
depth = post_processed_output[0]["predicted_depth_uint16"].detach().cpu().numpy()
|
| 31 |
-
depth = Image.fromarray(depth, mode="I;16")
|
| 32 |
-
depth.save("depth.png")
|
| 33 |
```
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
This is the Offical weights of ConFiDeNet
|
| 6 |
+
|
| 7 |
+
```python
|
| 8 |
+
from PIL import Image
|
| 9 |
+
import torch
|
| 10 |
+
from transformers import ConFiDeNetForDepthEstimation, ConFiDeNetImageProcessor
|
| 11 |
+
|
| 12 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 13 |
+
|
| 14 |
+
image = Image.open("<Image Path>").convert("RGB")
|
| 15 |
+
print(image.size)
|
| 16 |
+
# image.save("image.jpg")
|
| 17 |
+
|
| 18 |
+
image_processor = ConFiDeNetImageProcessor.from_pretrained("onkarsus13/ConFiDeNet-Large-VQ-32")
|
| 19 |
+
model = ConFiDeNetForDepthEstimation.from_pretrained("onkarsus13/ConFiDeNet-Large-VQ-32").to(device)
|
| 20 |
+
|
| 21 |
+
inputs = image_processor(images=image, return_tensors="pt").to(device)
|
| 22 |
+
|
| 23 |
+
with torch.no_grad():
|
| 24 |
+
outputs = model(**inputs)
|
| 25 |
+
|
| 26 |
+
post_processed_output = image_processor.post_process_depth_estimation(
|
| 27 |
+
outputs, target_sizes=[(image.height, image.width)],
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
depth = post_processed_output[0]["predicted_depth_uint16"].detach().cpu().numpy()
|
| 31 |
+
depth = Image.fromarray(depth, mode="I;16")
|
| 32 |
+
depth.save("depth.png")
|
| 33 |
```
|