Spaces:
Runtime error
Runtime error
s194649
commited on
Commit
·
0a1a41a
1
Parent(s):
2a1828c
fixed circular import
Browse files- inference.py +29 -2
- utils.py +0 -24
inference.py
CHANGED
|
@@ -10,9 +10,30 @@ import open3d as o3d
|
|
| 10 |
import pandas as pd
|
| 11 |
import plotly.express as px
|
| 12 |
import matplotlib.pyplot as plt
|
| 13 |
-
from utils import map_image_range
|
| 14 |
|
|
|
|
|
|
|
|
|
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
def PCL(mask, depth):
|
| 18 |
assert mask.shape == depth.shape
|
|
@@ -205,4 +226,10 @@ class SegmentPredictor:
|
|
| 205 |
sam_masks = []
|
| 206 |
for i,mask in enumerate(sam_result):
|
| 207 |
sam_masks.append((mask["segmentation"], str(i)))
|
| 208 |
-
return sam_masks
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
import pandas as pd
|
| 11 |
import plotly.express as px
|
| 12 |
import matplotlib.pyplot as plt
|
|
|
|
| 13 |
|
| 14 |
+
def map_image_range(image, min_value, max_value):
|
| 15 |
+
"""
|
| 16 |
+
Maps the values of a numpy image array to a specified range.
|
| 17 |
|
| 18 |
+
Args:
|
| 19 |
+
image (numpy.ndarray): Input image array with values ranging from 0 to 1.
|
| 20 |
+
min_value (float): Minimum value of the new range.
|
| 21 |
+
max_value (float): Maximum value of the new range.
|
| 22 |
+
|
| 23 |
+
Returns:
|
| 24 |
+
numpy.ndarray: Image array with values mapped to the specified range.
|
| 25 |
+
"""
|
| 26 |
+
# Ensure the input image is a numpy array
|
| 27 |
+
if not isinstance(image, np.ndarray):
|
| 28 |
+
raise ValueError("Input image must be a numpy array.")
|
| 29 |
+
|
| 30 |
+
# Ensure the image values are within the valid range (0 to 1)
|
| 31 |
+
if not (0 <= np.min(image) <= 1) or not (0 <= np.max(image) <= 1):
|
| 32 |
+
raise ValueError("Input image values must be in the range [0, 1].")
|
| 33 |
+
|
| 34 |
+
# Map the values to the specified range
|
| 35 |
+
mapped_image = (image - 0) * (max_value - min_value) / (1 - 0) + min_value
|
| 36 |
+
return mapped_image
|
| 37 |
|
| 38 |
def PCL(mask, depth):
|
| 39 |
assert mask.shape == depth.shape
|
|
|
|
| 226 |
sam_masks = []
|
| 227 |
for i,mask in enumerate(sam_result):
|
| 228 |
sam_masks.append((mask["segmentation"], str(i)))
|
| 229 |
+
return sam_masks
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
|
utils.py
CHANGED
|
@@ -196,27 +196,3 @@ def PCL3(image):
|
|
| 196 |
return fig
|
| 197 |
|
| 198 |
import numpy as np
|
| 199 |
-
|
| 200 |
-
def map_image_range(image, min_value, max_value):
|
| 201 |
-
"""
|
| 202 |
-
Maps the values of a numpy image array to a specified range.
|
| 203 |
-
|
| 204 |
-
Args:
|
| 205 |
-
image (numpy.ndarray): Input image array with values ranging from 0 to 1.
|
| 206 |
-
min_value (float): Minimum value of the new range.
|
| 207 |
-
max_value (float): Maximum value of the new range.
|
| 208 |
-
|
| 209 |
-
Returns:
|
| 210 |
-
numpy.ndarray: Image array with values mapped to the specified range.
|
| 211 |
-
"""
|
| 212 |
-
# Ensure the input image is a numpy array
|
| 213 |
-
if not isinstance(image, np.ndarray):
|
| 214 |
-
raise ValueError("Input image must be a numpy array.")
|
| 215 |
-
|
| 216 |
-
# Ensure the image values are within the valid range (0 to 1)
|
| 217 |
-
if not (0 <= np.min(image) <= 1) or not (0 <= np.max(image) <= 1):
|
| 218 |
-
raise ValueError("Input image values must be in the range [0, 1].")
|
| 219 |
-
|
| 220 |
-
# Map the values to the specified range
|
| 221 |
-
mapped_image = (image - 0) * (max_value - min_value) / (1 - 0) + min_value
|
| 222 |
-
return mapped_image
|
|
|
|
| 196 |
return fig
|
| 197 |
|
| 198 |
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|