psychofict commited on
Commit
3ab7b77
·
1 Parent(s): 975ce8d

Port to ZeroGPU: import spaces, decorate segment with @spaces.GPU

Browse files
Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -14,6 +14,8 @@ used for offline testing.
14
 
15
  import os
16
  import threading
 
 
17
  import numpy as np
18
  import torch
19
  from PIL import Image
@@ -113,6 +115,7 @@ def _legend_html(pairs, cfg):
113
  _EMPTY_LEGEND = "<div class='legend'><span class='muted'>Run a segmentation to see detected classes.</span></div>"
114
 
115
 
 
116
  @torch.no_grad()
117
  def segment(image, dataset=DEFAULT_DATASET, alpha=0.55):
118
  if image is None:
 
14
 
15
  import os
16
  import threading
17
+
18
+ import spaces # ZeroGPU: must be imported before torch so CUDA emulation is active at load time
19
  import numpy as np
20
  import torch
21
  from PIL import Image
 
115
  _EMPTY_LEGEND = "<div class='legend'><span class='muted'>Run a segmentation to see detected classes.</span></div>"
116
 
117
 
118
+ @spaces.GPU(duration=120)
119
  @torch.no_grad()
120
  def segment(image, dataset=DEFAULT_DATASET, alpha=0.55):
121
  if image is None: