Refactor point handling and default initialization.
Browse filesReplaced NumPy array usage with standard Python lists for points, simplifying code and reducing dependencies. Adjusted related logic to ensure compatibility with the updated data structure.
- handler.py +4 -4
- test_hf.py +3 -3
handler.py
CHANGED
|
@@ -86,9 +86,9 @@ class EndpointHandler:
|
|
| 86 |
visualization = data.get("visualization", False)
|
| 87 |
|
| 88 |
# Check the pixels to return if no pixel provided will return the [0,0] position
|
| 89 |
-
points = data.get("points",
|
| 90 |
-
|
| 91 |
-
|
| 92 |
|
| 93 |
# map = np.array(depth_map)
|
| 94 |
# print(map.shape)
|
|
@@ -116,7 +116,7 @@ class EndpointHandler:
|
|
| 116 |
"format": "base64_png"
|
| 117 |
}
|
| 118 |
else:
|
| 119 |
-
depths = [depth_map[i[1]][i[0]] for i in
|
| 120 |
result = {
|
| 121 |
"depths": depths
|
| 122 |
# "depth": normalized_depth.tolist(),
|
|
|
|
| 86 |
visualization = data.get("visualization", False)
|
| 87 |
|
| 88 |
# Check the pixels to return if no pixel provided will return the [0,0] position
|
| 89 |
+
points = data.get("points", [[0, 0]])
|
| 90 |
+
|
| 91 |
+
|
| 92 |
|
| 93 |
# map = np.array(depth_map)
|
| 94 |
# print(map.shape)
|
|
|
|
| 116 |
"format": "base64_png"
|
| 117 |
}
|
| 118 |
else:
|
| 119 |
+
depths = [depth_map[i[1]][i[0]] for i in points]
|
| 120 |
result = {
|
| 121 |
"depths": depths
|
| 122 |
# "depth": normalized_depth.tolist(),
|
test_hf.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import os
|
| 2 |
|
|
|
|
| 3 |
import requests
|
| 4 |
import base64
|
| 5 |
from PIL import Image
|
|
@@ -32,7 +33,7 @@ headers = {
|
|
| 32 |
# }
|
| 33 |
|
| 34 |
#----------------------------------------------------------------------------------
|
| 35 |
-
|
| 36 |
# Preparar los datos para la solicitud
|
| 37 |
payload = {
|
| 38 |
"inputs" : {
|
|
@@ -40,8 +41,7 @@ payload = {
|
|
| 40 |
},
|
| 41 |
"url" : "https://images.unsplash.com/photo-1586023492125-27b2c045efd7?fm=jpg&q=60&w=3000&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8aW50ZXJpb3IlMjBkZXNpZ258ZW58MHx8MHx8fDA%3D",
|
| 42 |
# "visualization": False,
|
| 43 |
-
"
|
| 44 |
-
"y": 60
|
| 45 |
|
| 46 |
}
|
| 47 |
|
|
|
|
| 1 |
import os
|
| 2 |
|
| 3 |
+
import numpy as np
|
| 4 |
import requests
|
| 5 |
import base64
|
| 6 |
from PIL import Image
|
|
|
|
| 33 |
# }
|
| 34 |
|
| 35 |
#----------------------------------------------------------------------------------
|
| 36 |
+
points = [[0, 0]]
|
| 37 |
# Preparar los datos para la solicitud
|
| 38 |
payload = {
|
| 39 |
"inputs" : {
|
|
|
|
| 41 |
},
|
| 42 |
"url" : "https://images.unsplash.com/photo-1586023492125-27b2c045efd7?fm=jpg&q=60&w=3000&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8aW50ZXJpb3IlMjBkZXNpZ258ZW58MHx8MHx8fDA%3D",
|
| 43 |
# "visualization": False,
|
| 44 |
+
"points": points
|
|
|
|
| 45 |
|
| 46 |
}
|
| 47 |
|