Update app.py
Browse files
app.py
CHANGED
@@ -24,11 +24,9 @@ if not os.path.exists("weights/sam_vit_h_4b8939.pth"):
|
|
24 |
# Add EfficientSAM to Python path
|
25 |
sys.path.append(os.path.abspath("EfficientSAM-main"))
|
26 |
|
27 |
-
|
28 |
-
subprocess.run(["git", "clone", "https://github.com/yformer/EfficientSAM.git"])
|
29 |
-
|
30 |
from segment_anything import sam_model_registry, SamAutomaticMaskGenerator
|
31 |
-
from efficient_sam.
|
32 |
|
33 |
# Constants
|
34 |
DEVICE = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
@@ -40,7 +38,7 @@ sam = sam_model_registry[MODEL_TYPE](checkpoint=CHECKPOINT_PATH).to(device=DEVIC
|
|
40 |
mask_generator_sam = SamAutomaticMaskGenerator(sam)
|
41 |
|
42 |
# Load EfficientSAM model
|
43 |
-
with zipfile.ZipFile("
|
44 |
zip_ref.extractall("weights")
|
45 |
efficient_sam_vits_model = build_efficient_sam_vits()
|
46 |
|
@@ -167,6 +165,3 @@ interface = gr.Interface(
|
|
167 |
)
|
168 |
|
169 |
interface.launch(debug=True)
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
24 |
# Add EfficientSAM to Python path
|
25 |
sys.path.append(os.path.abspath("EfficientSAM-main"))
|
26 |
|
27 |
+
# Import SAM and EfficientSAM modules
|
|
|
|
|
28 |
from segment_anything import sam_model_registry, SamAutomaticMaskGenerator
|
29 |
+
from efficient_sam.build_efficient_sam import build_efficient_sam_vits
|
30 |
|
31 |
# Constants
|
32 |
DEVICE = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
|
|
38 |
mask_generator_sam = SamAutomaticMaskGenerator(sam)
|
39 |
|
40 |
# Load EfficientSAM model
|
41 |
+
with zipfile.ZipFile("weights/efficient_sam_vits.pt.zip", 'r') as zip_ref:
|
42 |
zip_ref.extractall("weights")
|
43 |
efficient_sam_vits_model = build_efficient_sam_vits()
|
44 |
|
|
|
165 |
)
|
166 |
|
167 |
interface.launch(debug=True)
|
|
|
|
|
|