Adding examples with ImageSlider

#3
by ysharma HF staff - opened
Files changed (8) hide show
  1. .gitattributes +5 -0
  2. README.md +1 -1
  3. app.py +6 -4
  4. hair.jpg +3 -0
  5. maizi.jpg +3 -0
  6. videoframe_10273.png +3 -0
  7. videoframe_2168.png +3 -0
  8. 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: 5.19.0
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=gr.Image(type="pil"), # Only depth image output, no debug info
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

  • SHA256: 7b07a583db12943bc90c2429afeca0aca63450e8eb7a2f29314ffbb1acd8d710
  • Pointer size: 132 Bytes
  • Size of remote file: 2.33 MB
maizi.jpg ADDED

Git LFS Details

  • SHA256: c30cf9ee7bf1465c9d1ac1b28f5b5004abf0154e1ed104a0d5858e1e28d54e46
  • Pointer size: 132 Bytes
  • Size of remote file: 6.06 MB
videoframe_10273.png ADDED

Git LFS Details

  • SHA256: c100fb80f93d5d1b1133c2f37f187409b918a69b60a58b1c209bbab7553979a7
  • Pointer size: 132 Bytes
  • Size of remote file: 1.95 MB
videoframe_2168.png ADDED

Git LFS Details

  • SHA256: ad6f7a89e34db41702e31fb441442d4c9b2dce61e3e4202002929040fe0ea56c
  • Pointer size: 131 Bytes
  • Size of remote file: 950 kB
videoframe_3289.png ADDED

Git LFS Details

  • SHA256: c5ed7c8ca52f15a4c1bcb71a874d503c06a22d0d11365b50b2a94e2ef5e1e6bb
  • Pointer size: 132 Bytes
  • Size of remote file: 1.22 MB