atlury commited on
Commit
b44991c
·
verified ·
1 Parent(s): b764ffe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -7,6 +7,7 @@ import requests
7
  import torch
8
  import datetime
9
  import subprocess
 
10
 
11
  CUSTOM_CSS = """
12
  #output_box textarea {
@@ -24,7 +25,8 @@ if not os.path.exists(model_path):
24
  f.write(response.content)
25
 
26
  # Load the document segmentation model
27
- docseg_model = YOLO(model_path)
 
28
 
29
  def process_image(image):
30
  # Convert image to the format YOLO model expects
@@ -43,7 +45,7 @@ def process_image(image):
43
  return annotated_img, detected_areas_labels
44
 
45
  zero = torch.Tensor([0]).cuda()
46
- print(zero.device) # <-- 'cpu' 🤔
47
 
48
  @spaces.GPU
49
  def run_gpu() -> str:
 
7
  import torch
8
  import datetime
9
  import subprocess
10
+ import spaces # Ensure this import is correct and the module is available
11
 
12
  CUSTOM_CSS = """
13
  #output_box textarea {
 
25
  f.write(response.content)
26
 
27
  # Load the document segmentation model
28
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
29
+ docseg_model = YOLO(model_path).to(device)
30
 
31
  def process_image(image):
32
  # Convert image to the format YOLO model expects
 
45
  return annotated_img, detected_areas_labels
46
 
47
  zero = torch.Tensor([0]).cuda()
48
+ print(zero.device) # <-- 'cuda:0' if GPU is available, otherwise 'cpu'
49
 
50
  @spaces.GPU
51
  def run_gpu() -> str: