Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from gradio_client import Client, file
|
| 3 |
+
|
| 4 |
+
def predict_depth(image):
|
| 5 |
+
client = Client("prs-eth/marigold") # Adjust the username/modelname as needed
|
| 6 |
+
|
| 7 |
+
# Assuming 'image' is the input image file from the user
|
| 8 |
+
response = client.predict(
|
| 9 |
+
file(image), # Image file path
|
| 10 |
+
1, # Ensemble size (example value)
|
| 11 |
+
10, # Number of denoising steps (example value)
|
| 12 |
+
"0", # Processing resolution (example value)
|
| 13 |
+
file('path_to_sample_file_1.pdf'), # Sample file path for depth (16-bit)
|
| 14 |
+
file('path_to_sample_file_2.pdf'), # Sample file path for depth (32-bit)
|
| 15 |
+
file('path_to_sample_file_3.pdf'), # Sample file path for depth (color)
|
| 16 |
+
0.5, # Relative position of the near plane
|
| 17 |
+
0.9, # Relative position of the far plane
|
| 18 |
+
10, # Embossing level
|
| 19 |
+
2, # Smoothing filter size
|
| 20 |
+
-50, # Frame's near plane offset
|
| 21 |
+
api_name="/submit_depth_fn"
|
| 22 |
+
)
|
| 23 |
+
return response['image'] # Adjust according to the actual key in the response
|
| 24 |
+
|
| 25 |
+
# Gradio Interface
|
| 26 |
+
iface = gr.Interface(
|
| 27 |
+
fn=predict_depth,
|
| 28 |
+
inputs=gr.Image(type='filepath', label="Upload your image"),
|
| 29 |
+
outputs=gr.Image(type='auto', label="Depth Map Image"),
|
| 30 |
+
title="Depth Map Generator",
|
| 31 |
+
description="Upload an image to receive a depth map."
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
iface.launch()
|