Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,26 @@
|
|
1 |
-
from transformers import pipeline
|
2 |
import gradio as gr
|
|
|
|
|
3 |
|
4 |
-
#
|
5 |
-
|
|
|
|
|
|
|
6 |
|
7 |
-
def predict_depth(
|
8 |
-
#
|
9 |
-
output =
|
10 |
-
return output
|
11 |
|
12 |
-
|
13 |
-
interface = gr.Interface(
|
14 |
fn=predict_depth,
|
15 |
-
inputs=gr.inputs.Image(
|
16 |
-
outputs=gr.outputs.Image(label="Depth Map"),
|
17 |
-
title="
|
18 |
-
description="Upload an image
|
|
|
19 |
)
|
20 |
|
21 |
if __name__ == "__main__":
|
22 |
-
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
from marigold_depth_estimation import MarigoldPipeline, UNet2DConditionModel, AutoencoderKL, DDIMScheduler
|
4 |
|
5 |
+
# Instantiate the model components and the pipeline
|
6 |
+
unet_model = UNet2DConditionModel()
|
7 |
+
vae_model = AutoencoderKL()
|
8 |
+
scheduler = DDIMScheduler()
|
9 |
+
pipeline = MarigoldPipeline(unet=unet_model, vae=vae_model, scheduler=scheduler)
|
10 |
|
11 |
+
def predict_depth(input_image):
|
12 |
+
# Process the image and predict the depth map
|
13 |
+
output = pipeline(input_image)
|
14 |
+
return output.depth_image
|
15 |
|
16 |
+
iface = gr.Interface(
|
|
|
17 |
fn=predict_depth,
|
18 |
+
inputs=gr.inputs.Image(type="pil", label="Upload an Image"),
|
19 |
+
outputs=gr.outputs.Image(type="pil", label="Depth Map"),
|
20 |
+
title="Depth Map Generation",
|
21 |
+
description="Upload an image to generate its depth map using the Marigold Depth Estimation Model.",
|
22 |
+
examples=["sample1.jpg", "sample2.jpg"] # Optional: include example images in your repository
|
23 |
)
|
24 |
|
25 |
if __name__ == "__main__":
|
26 |
+
iface.launch()
|