NightRaven109 commited on
Commit
3352e23
·
verified ·
1 Parent(s): fd7e9e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -3,6 +3,7 @@ import cv2
3
  import torch
4
  import numpy as np
5
  import gradio as gr
 
6
  from huggingface_hub import hf_hub_download
7
  from depth_anything_v2.dpt import DepthAnythingV2
8
 
@@ -211,6 +212,7 @@ def initialize_model():
211
  # Initialize model at startup
212
  MODEL = initialize_model()
213
 
 
214
  def process_image(input_image):
215
  """
216
  Process the input image and return depth map and normal map
@@ -232,7 +234,7 @@ def process_image(input_image):
232
  # Normalize depth for visualization (0-255)
233
  depth_normalized = ((depth - depth.min()) / (depth.max() - depth.min()) * 255).astype(np.uint8)
234
 
235
- # Move model back to CPU after processing
236
  MODEL.to('cpu')
237
 
238
  # Get intensity map
@@ -251,6 +253,7 @@ def process_image(input_image):
251
 
252
  return depth_normalized, normal_map
253
 
 
254
  def gradio_interface(input_img):
255
  try:
256
  depth_raw, normal = process_image(input_img)
 
3
  import torch
4
  import numpy as np
5
  import gradio as gr
6
+ import spaces
7
  from huggingface_hub import hf_hub_download
8
  from depth_anything_v2.dpt import DepthAnythingV2
9
 
 
212
  # Initialize model at startup
213
  MODEL = initialize_model()
214
 
215
+ @spaces.GPU
216
  def process_image(input_image):
217
  """
218
  Process the input image and return depth map and normal map
 
234
  # Normalize depth for visualization (0-255)
235
  depth_normalized = ((depth - depth.min()) / (depth.max() - depth.min()) * 255).astype(np.uint8)
236
 
237
+ # Move model back to CPU
238
  MODEL.to('cpu')
239
 
240
  # Get intensity map
 
253
 
254
  return depth_normalized, normal_map
255
 
256
+ @spaces.GPU
257
  def gradio_interface(input_img):
258
  try:
259
  depth_raw, normal = process_image(input_img)