Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,13 +8,16 @@ import torch
|
|
8 |
import matplotlib.pyplot as plt
|
9 |
import numpy as np
|
10 |
from openai import OpenAI
|
|
|
11 |
|
12 |
# 初始化模型
|
13 |
clip_model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
|
14 |
clip_processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
15 |
blip_processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
16 |
blip_model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
|
17 |
-
sam_checkpoint =
|
|
|
|
|
18 |
sam = sam_model_registry["vit_h"](checkpoint=sam_checkpoint)
|
19 |
sam_predictor = SamPredictor(sam)
|
20 |
yolo_model = YOLO("yolov8x.pt") # 替换为实际 YOLO 模型路径
|
|
|
8 |
import matplotlib.pyplot as plt
|
9 |
import numpy as np
|
10 |
from openai import OpenAI
|
11 |
+
from huggingface_hub import hf_hub_download
|
12 |
|
13 |
# 初始化模型
|
14 |
clip_model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
|
15 |
clip_processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
16 |
blip_processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
17 |
blip_model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
|
18 |
+
sam_checkpoint = hf_hub_download(
|
19 |
+
repo_id="facebook/sam", filename="sam_vit_h_4b8939.pth", use_auth_token=False
|
20 |
+
)
|
21 |
sam = sam_model_registry["vit_h"](checkpoint=sam_checkpoint)
|
22 |
sam_predictor = SamPredictor(sam)
|
23 |
yolo_model = YOLO("yolov8x.pt") # 替换为实际 YOLO 模型路径
|