Spaces:
Sleeping
Sleeping
collinschreyer-dev commited on
Commit ·
e019c2e
1
Parent(s): f5a5bfe
Fix GPU: move @spaces.GPU to segment_tile and load_model instead of generator
Browse files
app.py
CHANGED
|
@@ -113,6 +113,7 @@ WORLD_EXT_MAP = {
|
|
| 113 |
# Model
|
| 114 |
# ---------------------------------------------------------------------------
|
| 115 |
|
|
|
|
| 116 |
def load_model():
|
| 117 |
global MODEL, PROCESSOR
|
| 118 |
if MODEL is None:
|
|
@@ -196,6 +197,7 @@ def compute_tile_windows(img_w: int, img_h: int, tile_size: int, overlap: int) -
|
|
| 196 |
# Per-tile segmentation
|
| 197 |
# ---------------------------------------------------------------------------
|
| 198 |
|
|
|
|
| 199 |
def segment_tile(tile_rgb: np.ndarray, prompt: str, confidence: float):
|
| 200 |
model, processor = load_model()
|
| 201 |
device = get_device()
|
|
@@ -508,7 +510,6 @@ def _fmt_time(secs: float) -> str:
|
|
| 508 |
PREVIEW_INTERVAL = 10 # update overlay every N tiles
|
| 509 |
|
| 510 |
|
| 511 |
-
@spaces.GPU(duration=3600) # request GPU for up to 60 minutes
|
| 512 |
def run_pipeline(
|
| 513 |
image_file,
|
| 514 |
world_file,
|
|
|
|
| 113 |
# Model
|
| 114 |
# ---------------------------------------------------------------------------
|
| 115 |
|
| 116 |
+
@spaces.GPU
|
| 117 |
def load_model():
|
| 118 |
global MODEL, PROCESSOR
|
| 119 |
if MODEL is None:
|
|
|
|
| 197 |
# Per-tile segmentation
|
| 198 |
# ---------------------------------------------------------------------------
|
| 199 |
|
| 200 |
+
@spaces.GPU
|
| 201 |
def segment_tile(tile_rgb: np.ndarray, prompt: str, confidence: float):
|
| 202 |
model, processor = load_model()
|
| 203 |
device = get_device()
|
|
|
|
| 510 |
PREVIEW_INTERVAL = 10 # update overlay every N tiles
|
| 511 |
|
| 512 |
|
|
|
|
| 513 |
def run_pipeline(
|
| 514 |
image_file,
|
| 515 |
world_file,
|