prasadsachin commited on
Commit
201ca3d
·
verified ·
1 Parent(s): ab6fee2

Update README.md with new model card content

Browse files
Files changed (1) hide show
  1. README.md +59 -14
README.md CHANGED
@@ -1,17 +1,62 @@
1
  ---
2
  library_name: keras-hub
3
  ---
4
- This is a [`DepthAnything` model](https://keras.io/api/keras_hub/models/depth_anything) uploaded using the KerasHub library and can be used with JAX, TensorFlow, and PyTorch backends.
5
- Model config:
6
- * **name:** depth_anything_backbone
7
- * **trainable:** True
8
- * **dtype:** {'module': 'keras', 'class_name': 'DTypePolicy', 'config': {'name': 'float32'}, 'registered_name': None}
9
- * **image_encoder:** {'module': 'keras_hub.src.models.dinov2.dinov2_backbone', 'class_name': 'DINOV2Backbone', 'config': {'name': 'dinov2_backbone', 'trainable': True, 'dtype': {'module': 'keras', 'class_name': 'DTypePolicy', 'config': {'name': 'float32'}, 'registered_name': None}, 'patch_size': 14, 'num_layers': 24, 'hidden_dim': 1024, 'num_heads': 16, 'intermediate_dim': 4096, 'layer_scale_init_value': 1.0, 'num_register_tokens': 0, 'use_mask_token': True, 'use_swiglu_ffn': False, 'dropout_rate': 0.0, 'drop_path_rate': 0.0, 'image_shape': [518, 518, 3], 'position_embedding_shape': [518, 518], 'antialias_in_interpolation': False, 'apply_layernorm': True}, 'registered_name': 'keras_hub>DINOV2Backbone'}
10
- * **reassemble_factors:** [4, 2, 1, 0.5]
11
- * **neck_hidden_dims:** [256, 512, 1024, 1024]
12
- * **fusion_hidden_dim:** 256
13
- * **head_hidden_dim:** 32
14
- * **head_in_index:** -1
15
- * **feature_keys:** ['stage5', 'stage12', 'stage18', 'stage24']
16
-
17
- This model card has been generated automatically and should be completed by the model author. See [Model Cards documentation](https://huggingface.co/docs/hub/model-cards) for more information.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  library_name: keras-hub
3
  ---
4
+ ### Model Overview
5
+
6
+
7
+ ## Example Usage
8
+ ```python
9
+ import keras
10
+ import numpy as np
11
+ import requests
12
+ from PIL import Image
13
+
14
+ from keras_hub.src.models.depth_anything.depth_anything_depth_estimator import (
15
+ DepthAnythingDepthEstimator,
16
+ )
17
+
18
+ image = Image.open(requests.get("http://images.cocodataset.org/val2017/000000039769.jpg", stream=True).raw)
19
+ image = image.resize((518, 518))
20
+ depth_estimator = DepthAnythingDepthEstimator.from_preset(
21
+ "depth_anything_v2_base,
22
+ depth_estimation_type="relative",
23
+ max_depth=None,
24
+ )
25
+ images = np.expand_dims(np.array(image).astype("float32"), axis=0)
26
+ outputs = depth_estimator.predict({"images": images})["depths"]
27
+ depth = keras.ops.nn.relu(outputs[0, ..., 0])
28
+ depth = (depth - keras.ops.min(depth)) / (
29
+ keras.ops.max(depth) - keras.ops.min(depth)
30
+ )
31
+ depth = keras.ops.convert_to_numpy(depth) * 255
32
+ Image.fromarray(depth.astype("uint8")).save("depth_map.png")
33
+ ```
34
+
35
+ ## Example Usage with Hugging Face URI
36
+
37
+ ```python
38
+ import keras
39
+ import numpy as np
40
+ import requests
41
+ from PIL import Image
42
+
43
+ from keras_hub.src.models.depth_anything.depth_anything_depth_estimator import (
44
+ DepthAnythingDepthEstimator,
45
+ )
46
+
47
+ image = Image.open(requests.get("http://images.cocodataset.org/val2017/000000039769.jpg", stream=True).raw)
48
+ image = image.resize((518, 518))
49
+ depth_estimator = DepthAnythingDepthEstimator.from_preset(
50
+ "depth_anything_v2_base,
51
+ depth_estimation_type="relative",
52
+ max_depth=None,
53
+ )
54
+ images = np.expand_dims(np.array(image).astype("float32"), axis=0)
55
+ outputs = depth_estimator.predict({"images": images})["depths"]
56
+ depth = keras.ops.nn.relu(outputs[0, ..., 0])
57
+ depth = (depth - keras.ops.min(depth)) / (
58
+ keras.ops.max(depth) - keras.ops.min(depth)
59
+ )
60
+ depth = keras.ops.convert_to_numpy(depth) * 255
61
+ Image.fromarray(depth.astype("uint8")).save("depth_map.png")
62
+ ```