StefanoBergia commited on
Commit
368f089
·
1 Parent(s): cf6ee13

fix cuda check

Browse files
Files changed (1) hide show
  1. enhanced_app.py +6 -3
enhanced_app.py CHANGED
@@ -52,6 +52,9 @@ try:
52
  except ImportError:
53
  print("DepthAnythingV2 not available. Using precomputed examples only.")
54
  DEPTH_AVAILABLE = False
 
 
 
55
 
56
  # Set environment variable to disable xFormers
57
  os.environ['XFORMERS_DISABLED'] = '1'
@@ -591,7 +594,7 @@ class PrecomputedExamplesManager:
591
  """Create a preview thumbnail from RGB input image."""
592
  try:
593
  image = Image.open(rgb_path)
594
- image.thumbnail((200, 150), Image.Resampling.LANCZOS)
595
  return image
596
 
597
  except Exception as e:
@@ -898,7 +901,7 @@ def create_gradio_interface():
898
  with gr.Row():
899
  # Left Column: Controls and Input
900
  with gr.Column(scale=1):
901
- if DEPTH_AVAILABLE:
902
  gr.Markdown("### Upload Image")
903
 
904
  uploaded_image = gr.Image(
@@ -946,7 +949,7 @@ def create_gradio_interface():
946
  gr.Markdown("#### 3D Point Cloud")
947
  pointcloud_output = gr.Plot(label="Interactive 3D Point Cloud (Colored by Segmentation)")
948
 
949
- if DEPTH_AVAILABLE:
950
  upload_btn.click(
951
  fn=process_uploaded_image,
952
  inputs=[uploaded_image],
 
52
  except ImportError:
53
  print("DepthAnythingV2 not available. Using precomputed examples only.")
54
  DEPTH_AVAILABLE = False
55
+
56
+
57
+ CUDA_AVAILABLE = torch.cuda.is_available()
58
 
59
  # Set environment variable to disable xFormers
60
  os.environ['XFORMERS_DISABLED'] = '1'
 
594
  """Create a preview thumbnail from RGB input image."""
595
  try:
596
  image = Image.open(rgb_path)
597
+ image.thumbnail((600, 450), Image.Resampling.LANCZOS)
598
  return image
599
 
600
  except Exception as e:
 
901
  with gr.Row():
902
  # Left Column: Controls and Input
903
  with gr.Column(scale=1):
904
+ if CUDA_AVAILABLE:
905
  gr.Markdown("### Upload Image")
906
 
907
  uploaded_image = gr.Image(
 
949
  gr.Markdown("#### 3D Point Cloud")
950
  pointcloud_output = gr.Plot(label="Interactive 3D Point Cloud (Colored by Segmentation)")
951
 
952
+ if CUDA_AVAILABLE:
953
  upload_btn.click(
954
  fn=process_uploaded_image,
955
  inputs=[uploaded_image],