Spaces:
Running
on
Zero
Running
on
Zero
Adding examples with ImageSlider
#3
by
ysharma
HF staff
- opened
- .gitattributes +5 -0
- README.md +1 -1
- app.py +6 -4
- hair.jpg +3 -0
- maizi.jpg +3 -0
- videoframe_10273.png +3 -0
- videoframe_2168.png +3 -0
- videoframe_3289.png +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,8 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
hair.jpg filter=lfs diff=lfs merge=lfs -text
|
37 |
+
maizi.jpg filter=lfs diff=lfs merge=lfs -text
|
38 |
+
videoframe_10273.png filter=lfs diff=lfs merge=lfs -text
|
39 |
+
videoframe_2168.png filter=lfs diff=lfs merge=lfs -text
|
40 |
+
videoframe_3289.png filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -4,7 +4,7 @@ emoji: 💻
|
|
4 |
colorFrom: blue
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
|
|
4 |
colorFrom: blue
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.44.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
app.py
CHANGED
@@ -9,6 +9,7 @@ from torchvision.transforms import Compose
|
|
9 |
import cv2
|
10 |
from huggingface_hub import hf_hub_download
|
11 |
from safetensors.torch import load_file
|
|
|
12 |
import spaces
|
13 |
|
14 |
# Helper function to load model from Hugging Face
|
@@ -69,7 +70,7 @@ def process_image(image, model, device):
|
|
69 |
|
70 |
# Convert to a PIL image
|
71 |
depth_image = Image.fromarray(depth_colored_hwc)
|
72 |
-
return depth_image
|
73 |
|
74 |
# Gradio interface function with GPU support
|
75 |
@spaces.GPU
|
@@ -114,10 +115,11 @@ def gradio_interface(image):
|
|
114 |
iface = gr.Interface(
|
115 |
fn=gradio_interface,
|
116 |
inputs=gr.Image(type="pil"), # Only image input, no mode selection
|
117 |
-
outputs=
|
118 |
title="Depth Estimation Demo",
|
119 |
-
description="Upload an image to see the depth estimation results. Our model is running on GPU for faster processing."
|
120 |
-
|
|
|
121 |
|
122 |
# Launch the Gradio interface
|
123 |
iface.launch()
|
|
|
9 |
import cv2
|
10 |
from huggingface_hub import hf_hub_download
|
11 |
from safetensors.torch import load_file
|
12 |
+
from gradio_imageslider import ImageSlider
|
13 |
import spaces
|
14 |
|
15 |
# Helper function to load model from Hugging Face
|
|
|
70 |
|
71 |
# Convert to a PIL image
|
72 |
depth_image = Image.fromarray(depth_colored_hwc)
|
73 |
+
return image, depth_image
|
74 |
|
75 |
# Gradio interface function with GPU support
|
76 |
@spaces.GPU
|
|
|
115 |
iface = gr.Interface(
|
116 |
fn=gradio_interface,
|
117 |
inputs=gr.Image(type="pil"), # Only image input, no mode selection
|
118 |
+
outputs = ImageSlider(label="Depth slider", type="pil", slider_color="pink"), # Depth image out with a slider
|
119 |
title="Depth Estimation Demo",
|
120 |
+
description="Upload an image to see the depth estimation results. Our model is running on GPU for faster processing.",
|
121 |
+
examples=["maizi.jpg", "hair.jpg", "videoframe_10273.png", "videoframe_2168.png", "videoframe_3289.png"],
|
122 |
+
cache_examples=True,)
|
123 |
|
124 |
# Launch the Gradio interface
|
125 |
iface.launch()
|
hair.jpg
ADDED
![]() |
Git LFS Details
|
maizi.jpg
ADDED
![]() |
Git LFS Details
|
videoframe_10273.png
ADDED
![]() |
Git LFS Details
|
videoframe_2168.png
ADDED
![]() |
Git LFS Details
|
videoframe_3289.png
ADDED
![]() |
Git LFS Details
|