Downloads · 30 days
0
vishal-adithya/depth-estimator
depth-estimator is a depth estimation model from vishal-adithya. Use it for the depth estimation task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
- Vishal Adithya.A This project demonstrates a depth estimation XgBoost Regressor model that predicts the average depth of images provided using features extracted from a pre-trained ResNet50 model.The model was train…
Downloads · 30 days
0
Access
Public
Updated Jan 18, 2025
Repo size
524 KB
Likes
3
Public
Click a slice to open those files.
.pkl121 KB · 96%
From the Hugging Face model README
This project demonstrates a depth estimation XgBoost Regressor model that predicts the average depth of images provided using features extracted from a pre-trained ResNet50 model.The model was trained upon the NYUv2 dataset (0jl/NYUv2). The trained model is saved using Python's pickle library for easy deployment and reuse.
The model is saved as model.pkl using pickle. You can load and use it as follows:
with open("model.pkl", "rb") as f:
model = pickle.load(f)
features = extract_features("path/to/image.jpg")
predicted_depth = model.predict([features])
print(predicted_depth[0])
NOTE: extract_features() is a predefined function in the original code which uses ResNet50 to extract features out of the image.
preprocess_input function from TensorFlow's ResNet50 module.numpypicklexgboostdatasetstensorflowscikitlearnInstall the dependencies using pip:
pip install numpy tensorflow xgboost datasets scikit-learn
If you want to retrain the model, follow these steps:
from datasets import load_dataset
dataset = load_dataset("0jl/NYUv2")
model = ResNet50(weights="imagenet", include_top=False, pooling="avg")
from PIL import Image
def extract_features(image_path):
image_array = preprocess_input(image_array)
features = model.predict(image_array)
return features.flatten()
regressor = XGBRegressor()
regressor.fit(X_train, y_train)
with open("model.pkl", "wb") as f:
pickle.dump(regressor, f)
NOTE: This pipeline has just the base fundamental code more additional parameter tunings and preprocessing steps were being conducted during the training of the original model.
This project is licensed under the Apache License 2.0.