Update depth_estimation.py
Browse files- depth_estimation.py +4 -1
depth_estimation.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
# Importing the requirements
|
2 |
import numpy as np
|
3 |
-
import torch
|
4 |
from PIL import Image
|
|
|
5 |
from transformers import DPTImageProcessor, DPTForDepthEstimation
|
6 |
|
7 |
|
@@ -21,6 +21,9 @@ def process_image(image):
|
|
21 |
Returns:
|
22 |
PIL.Image.Image: The formatted depth map as an image.
|
23 |
"""
|
|
|
|
|
|
|
24 |
|
25 |
# Preprocess the image for the model
|
26 |
encoding = feature_extractor(image, return_tensors="pt")
|
|
|
1 |
# Importing the requirements
|
2 |
import numpy as np
|
|
|
3 |
from PIL import Image
|
4 |
+
import torch
|
5 |
from transformers import DPTImageProcessor, DPTForDepthEstimation
|
6 |
|
7 |
|
|
|
21 |
Returns:
|
22 |
PIL.Image.Image: The formatted depth map as an image.
|
23 |
"""
|
24 |
+
# Check if the image is provided
|
25 |
+
if not image:
|
26 |
+
gr.error("No image provided")
|
27 |
|
28 |
# Preprocess the image for the model
|
29 |
encoding = feature_extractor(image, return_tensors="pt")
|