Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Initialize the pipeline with the Marigold model hosted on Hugging Face
|
| 5 |
+
model = pipeline("image-to-image", model="prs-eth/marigold-depth-v1-0")
|
| 6 |
+
|
| 7 |
+
def predict_depth(image):
|
| 8 |
+
# Generate a depth map from the input image using the model
|
| 9 |
+
output = model(image)
|
| 10 |
+
return output['output_image'] # Ensure this key matches the output of your model
|
| 11 |
+
|
| 12 |
+
# Set up the Gradio interface
|
| 13 |
+
interface = gr.Interface(
|
| 14 |
+
fn=predict_depth,
|
| 15 |
+
inputs=gr.inputs.Image(shape=(512, 512), label="Upload Image"),
|
| 16 |
+
outputs=gr.outputs.Image(label="Depth Map"),
|
| 17 |
+
title="Marigold Depth Map Estimation",
|
| 18 |
+
description="Upload an image and the model will estimate and display its depth map."
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
if __name__ == "__main__":
|
| 22 |
+
interface.launch()
|