fix: temporarily migrate away from ZeroGPU
Browse files
app.py
CHANGED
@@ -1,11 +1,8 @@
|
|
1 |
from typing import Any, Dict
|
2 |
|
3 |
-
import spaces
|
4 |
-
|
5 |
import cv2
|
6 |
import gradio as gr
|
7 |
import numpy as np
|
8 |
-
import torch
|
9 |
from gradio_image_annotation import image_annotator
|
10 |
from sam2 import load_model
|
11 |
from sam2.sam2_image_predictor import SAM2ImagePredictor
|
@@ -13,14 +10,12 @@ from sam2.sam2_image_predictor import SAM2ImagePredictor
|
|
13 |
from src.plot_utils import export_mask
|
14 |
|
15 |
|
16 |
-
@spaces.GPU()
|
17 |
def predict(model_choice, annotations: Dict[str, Any]):
|
18 |
-
# device = "cuda" if torch.cuda.is_available() else "cpu"
|
19 |
-
torch.autocast(device_type="cuda", dtype=torch.bfloat16).__enter__()
|
20 |
sam2_model = load_model(
|
21 |
variant=model_choice,
|
22 |
ckpt_path=f"assets/checkpoints/sam2_hiera_{model_choice}.pt",
|
23 |
-
device="
|
24 |
)
|
25 |
predictor = SAM2ImagePredictor(sam2_model) # type:ignore
|
26 |
predictor.set_image(annotations["image"])
|
|
|
1 |
from typing import Any, Dict
|
2 |
|
|
|
|
|
3 |
import cv2
|
4 |
import gradio as gr
|
5 |
import numpy as np
|
|
|
6 |
from gradio_image_annotation import image_annotator
|
7 |
from sam2 import load_model
|
8 |
from sam2.sam2_image_predictor import SAM2ImagePredictor
|
|
|
10 |
from src.plot_utils import export_mask
|
11 |
|
12 |
|
13 |
+
# @spaces.GPU()
|
14 |
def predict(model_choice, annotations: Dict[str, Any]):
|
|
|
|
|
15 |
sam2_model = load_model(
|
16 |
variant=model_choice,
|
17 |
ckpt_path=f"assets/checkpoints/sam2_hiera_{model_choice}.pt",
|
18 |
+
device="cpu",
|
19 |
)
|
20 |
predictor = SAM2ImagePredictor(sam2_model) # type:ignore
|
21 |
predictor.set_image(annotations["image"])
|