Spaces:
Build error
Build error
File size: 826 Bytes
3675918 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import numpy as np
def depth_norm(x, maxDepth):
return maxDepth / x
def predict(model, images, minDepth=10, maxDepth=1000, batch_size=2):
# Support multiple RGBs, one RGB image, even grayscale
if len(images.shape) < 3: images = np.stack((images, images, images), axis=2)
if len(images.shape) < 4: images = images.reshape((1, images.shape[0], images.shape[1], images.shape[2]))
# Compute predictions
predictions = model.predict(images, batch_size=batch_size)
# Put in expected range
return np.clip(depth_norm(predictions, maxDepth=maxDepth), minDepth, maxDepth) / maxDepth
def load_images(image_files):
loaded_images = []
for file in image_files:
x = np.clip(file.reshape(480, 640, 3) / 255, 0, 1)
loaded_images.append(x)
return np.stack(loaded_images, axis=0)
|