lichih commited on
Commit
b0f9d98
·
verified ·
1 Parent(s): d3b0891

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -22,8 +22,13 @@ class Classifier:
22
 
23
  @spaces.GPU(duration=60)
24
  def __init__(
25
- self, model_path="Litton-7type-visual-landscape-model.pth", device="cuda:0"
26
  ):
 
 
 
 
 
27
  self.device = device
28
  self.model = torch.load(
29
  model_path, map_location=self.device, weights_only=False
 
22
 
23
  @spaces.GPU(duration=60)
24
  def __init__(
25
+ self, model_path="Litton-7type-visual-landscape-model.pth", device=None
26
  ):
27
+ if device is None:
28
+ self.device = "cuda:0" if torch.cuda.is_available() else "cpu"
29
+ else:
30
+ self.device = device
31
+
32
  self.device = device
33
  self.model = torch.load(
34
  model_path, map_location=self.device, weights_only=False