Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,24 +14,6 @@ from segment_anything import SamPredictor, sam_model_registry
|
|
14 |
from yolo_world.models.detectors import build_detector
|
15 |
from mmcv import Config
|
16 |
|
17 |
-
# 初始化环境
|
18 |
-
def install_requirements():
|
19 |
-
try:
|
20 |
-
# 优先安装基础依赖
|
21 |
-
subprocess.run(["pip", "install", "-r", "base_requirements.txt"], check=True)
|
22 |
-
# 安装其他依赖
|
23 |
-
subprocess.run(["pip", "install", "-r", "additional_requirements.txt"], check=True)
|
24 |
-
except subprocess.CalledProcessError as e:
|
25 |
-
print(f"依赖安装失败: {e}")
|
26 |
-
exit(1)
|
27 |
-
|
28 |
-
# 检查是否需要安装依赖
|
29 |
-
if not os.path.exists("requirements_installed.txt"):
|
30 |
-
install_requirements()
|
31 |
-
# 创建标志文件,避免重复安装
|
32 |
-
with open("requirements_installed.txt", "w") as f:
|
33 |
-
f.write("installed")
|
34 |
-
|
35 |
# 初始化模型
|
36 |
clip_model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
|
37 |
clip_processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
|
|
14 |
from yolo_world.models.detectors import build_detector
|
15 |
from mmcv import Config
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
# 初始化模型
|
18 |
clip_model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
|
19 |
clip_processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|