NandiniLokeshReddy
commited on
Commit
·
e0b4b52
1
Parent(s):
6c5760f
Try2
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ import gradio as gr
|
|
10 |
import os
|
11 |
import requests
|
12 |
import zipfile
|
|
|
13 |
|
14 |
# Ensure the necessary model files are available
|
15 |
def download_file(url, destination):
|
@@ -17,20 +18,13 @@ def download_file(url, destination):
|
|
17 |
with open(destination, 'wb') as f:
|
18 |
f.write(response.content)
|
19 |
|
20 |
-
#
|
21 |
-
|
22 |
-
|
23 |
-
download_file("https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth", "weights/sam_vit_h_4b8939.pth")
|
24 |
-
|
25 |
-
# Clone EfficientSAM repository if not already cloned
|
26 |
-
if not os.path.exists("EfficientSAM"):
|
27 |
-
os.makedirs("EfficientSAM", exist_ok=True)
|
28 |
-
os.system("git clone https://github.com/yformer/EfficientSAM.git EfficientSAM")
|
29 |
|
|
|
30 |
os.chdir("EfficientSAM")
|
31 |
|
32 |
-
!pip install git+https://github.com/facebookresearch/segment-anything.git
|
33 |
-
|
34 |
from segment_anything.utils.amg import (
|
35 |
batched_mask_to_box,
|
36 |
calculate_stability_score,
|
@@ -166,3 +160,4 @@ interface = gr.Interface(
|
|
166 |
|
167 |
interface.launch(debug=True)
|
168 |
|
|
|
|
10 |
import os
|
11 |
import requests
|
12 |
import zipfile
|
13 |
+
import subprocess
|
14 |
|
15 |
# Ensure the necessary model files are available
|
16 |
def download_file(url, destination):
|
|
|
18 |
with open(destination, 'wb') as f:
|
19 |
f.write(response.content)
|
20 |
|
21 |
+
# Install the necessary packages
|
22 |
+
subprocess.run(["pip", "install", "git+https://github.com/facebookresearch/segment-anything.git"])
|
23 |
+
subprocess.run(["git", "clone", "https://github.com/yformer/EfficientSAM.git"])
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
# Change directory to EfficientSAM
|
26 |
os.chdir("EfficientSAM")
|
27 |
|
|
|
|
|
28 |
from segment_anything.utils.amg import (
|
29 |
batched_mask_to_box,
|
30 |
calculate_stability_score,
|
|
|
160 |
|
161 |
interface.launch(debug=True)
|
162 |
|
163 |
+
|