From a728fe529e919d385e9f4f1cbf306293546e4de8 Mon Sep 17 00:00:00 2001 From: Ryan Avery Date: Sun, 6 Oct 2024 20:50:27 -0700 Subject: [PATCH] support mps device along with cpu and gpu --- app/requirements.txt | 2 +- app/utils/sam2.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/requirements.txt b/app/requirements.txt index c3dc9a5..38c35d8 100755 --- a/app/requirements.txt +++ b/app/requirements.txt @@ -6,7 +6,7 @@ rtree==1.0.1 typing-extensions>=4.10.0 maplibre>=0.2.6 shiny>=0.7.0 -segment-geospatial==0.11.0 +segment-geospatial==0.11.1 geopandas==0.14.4 shapely==2.0.4 rasterio==1.3.9 diff --git a/app/utils/sam2.py b/app/utils/sam2.py index 5c2e67c..382aa87 100755 --- a/app/utils/sam2.py +++ b/app/utils/sam2.py @@ -1,5 +1,5 @@ import os -from samgeo import SamGeo2 +from samgeo import SamGeo2, choose_device import torch from utils.utils import ( generate_geojson, @@ -10,7 +10,7 @@ from utils.logger_config import log # Initialize the SAM model -device = "cuda" if torch.cuda.is_available() else "cpu" +device = choose_device() log.info(f"Using device: {device}") sam2 = SamGeo2( model_id="sam2-hiera-large",