Update app.py
Browse files
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=
|
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
|