Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,18 @@ import gradio as gr
|
|
| 6 |
from segment_anything import SamPredictor, sam_model_registry
|
| 7 |
from groundingdino.util.inference import load_model, predict, annotate
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
grounding_dino_config = "groundingdino/config/GroundingDINO_SwinT_OGC.py"
|
| 10 |
grounding_dino_weights = 'groundingdino_swift_ogc.path'
|
| 11 |
|
|
|
|
| 6 |
from segment_anything import SamPredictor, sam_model_registry
|
| 7 |
from groundingdino.util.inference import load_model, predict, annotate
|
| 8 |
|
| 9 |
+
checkpoint_path = "./sam_vit_h_4b8939.pth" # Will be downloaded programmatically
|
| 10 |
+
|
| 11 |
+
# Download programmatically using hf_hub_download
|
| 12 |
+
from huggingface_hub import hf_hub_download
|
| 13 |
+
|
| 14 |
+
checkpoint_path = hf_hub_download(
|
| 15 |
+
repo_id="HCMUE-Research/SAM-vit-h",
|
| 16 |
+
filename="sam_vit_h_4b8939.pth"
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
sam = sam_model_registry["vit_h"](checkpoint=checkpoint_path)
|
| 20 |
+
|
| 21 |
grounding_dino_config = "groundingdino/config/GroundingDINO_SwinT_OGC.py"
|
| 22 |
grounding_dino_weights = 'groundingdino_swift_ogc.path'
|
| 23 |
|