babmakkah01 commited on
Commit
2a71692
1 Parent(s): a232af2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +31 -23
README.md CHANGED
@@ -1,23 +1,31 @@
1
- ---
2
- license: unknown
3
- datasets:
4
- - fka/awesome-chatgpt-prompts
5
- - wikimedia/wikipedia
6
- - HuggingFaceH4/no_robots
7
- - vivym/midjourney-messages
8
- - berkeley-nest/Nectar
9
- - Lin-Chen/ShareGPT4V
10
- - nvidia/HelpSteer
11
- - Open-Orca/SlimOrca
12
- - gaia-benchmark/GAIA
13
- - MMMU/MMMU
14
- language:
15
- - ar
16
- - en
17
- metrics:
18
- - accuracy
19
- library_name: open_clip
20
- tags:
21
- - code
22
- - finance
23
- ---
 
 
 
 
 
 
 
 
 
1
+ from transformers import DPTImageProcessor, DPTForDepthEstimation
2
+ import torch
3
+ import numpy as np
4
+ from PIL import Image
5
+ import requests
6
+
7
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
8
+ image = Image.open(requests.get(url, stream=True).raw)
9
+
10
+ processor = DPTImageProcessor.from_pretrained("Intel/dpt-large")
11
+ model = DPTForDepthEstimation.from_pretrained("Intel/dpt-large")
12
+
13
+ # prepare image for the model
14
+ inputs = processor(images=image, return_tensors="pt")
15
+
16
+ with torch.no_grad():
17
+ outputs = model(**inputs)
18
+ predicted_depth = outputs.predicted_depth
19
+
20
+ # interpolate to original size
21
+ prediction = torch.nn.functional.interpolate(
22
+ predicted_depth.unsqueeze(1),
23
+ size=image.size[::-1],
24
+ mode="bicubic",
25
+ align_corners=False,
26
+ )
27
+
28
+ # visualize the prediction
29
+ output = prediction.squeeze().cpu().numpy()
30
+ formatted = (output * 255 / np.max(output)).astype("uint8")
31
+ depth = Image.fromarray(formatted)