P3ngLiu commited on
Commit
4c7ae41
·
1 Parent(s): 5d9f81c
Files changed (2) hide show
  1. README.md +1 -1
  2. demo/gradio_demo_with_sam3.py +12 -3
README.md CHANGED
@@ -5,7 +5,7 @@ colorFrom: pink
5
  colorTo: green
6
  sdk: gradio
7
  sdk_version: 5.49.1
8
- app_file: app.py
9
  pinned: false
10
  license: apache-2.0
11
  short_description: Complex text label dection using SAM3 with VLM-FO1
 
5
  colorTo: green
6
  sdk: gradio
7
  sdk_version: 5.49.1
8
+ app_file: demo/gradio_demo_with_sam3.py
9
  pinned: false
10
  license: apache-2.0
11
  short_description: Complex text label dection using SAM3 with VLM-FO1
demo/gradio_demo_with_sam3.py CHANGED
@@ -310,15 +310,24 @@ def launch_demo():
310
  if __name__ == "__main__":
311
  # model_path = './resources/VLM-FO1_Qwen2.5-VL-3B-v01'
312
  # sam3_model_path = './resources/sam3/sam3.pt'
313
- from modelscope import snapshot_download
314
- model_dir = snapshot_download('facebook/sam3', allow_patterns='sam3.pt')
 
 
 
 
 
 
 
 
 
315
 
316
  model_path = 'omlab/VLM-FO1_Qwen2.5-VL-3B-v01'
317
  tokenizer, model, image_processors = load_pretrained_model(
318
  model_path=model_path,
319
  device="cuda:0",
320
  )
321
- sam3_model = build_sam3_image_model(checkpoint_path=model_dir+'/sam3.pt', device="cuda",bpe_path='/home/user/app/detect_tools/sam3/assets/bpe_simple_vocab_16e6.txt.gz')
322
  sam3_processor = Sam3Processor(sam3_model, confidence_threshold=0.0, device="cuda")
323
 
324
  demo = launch_demo()
 
310
  if __name__ == "__main__":
311
  # model_path = './resources/VLM-FO1_Qwen2.5-VL-3B-v01'
312
  # sam3_model_path = './resources/sam3/sam3.pt'
313
+ # from modelscope import snapshot_download
314
+ # model_dir = snapshot_download('facebook/sam3', allow_patterns='sam3.pt')
315
+
316
+ # from huggingface_hub import hf_hub_download
317
+ # model_dir = hf_hub_download(
318
+ # repo_id='facebook/sam3',
319
+ # filename='sam3.pt',
320
+ # local_dir="./sam3_model"
321
+
322
+ import os
323
+ exit_code = os.system(f"wget -c https://airesources.oss-cn-hangzhou.aliyuncs.com/lp/wheel/sam3.pt")
324
 
325
  model_path = 'omlab/VLM-FO1_Qwen2.5-VL-3B-v01'
326
  tokenizer, model, image_processors = load_pretrained_model(
327
  model_path=model_path,
328
  device="cuda:0",
329
  )
330
+ sam3_model = build_sam3_image_model(checkpoint_path='./sam3.pt', device="cuda",bpe_path='/home/user/app/detect_tools/sam3/assets/bpe_simple_vocab_16e6.txt.gz')
331
  sam3_processor = Sam3Processor(sam3_model, confidence_threshold=0.0, device="cuda")
332
 
333
  demo = launch_demo()