File size: 784 Bytes
304db7c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from transformers import pipeline
import gradio as gr

# Initialize the pipeline with the Marigold model hosted on Hugging Face
model = pipeline("image-to-image", model="prs-eth/marigold-depth-v1-0")

def predict_depth(image):
    # Generate a depth map from the input image using the model
    output = model(image)
    return output['output_image']  # Ensure this key matches the output of your model

# Set up the Gradio interface
interface = gr.Interface(
    fn=predict_depth,
    inputs=gr.inputs.Image(shape=(512, 512), label="Upload Image"),
    outputs=gr.outputs.Image(label="Depth Map"),
    title="Marigold Depth Map Estimation",
    description="Upload an image and the model will estimate and display its depth map."
)

if __name__ == "__main__":
    interface.launch()