🚀 ไม่มีเวลาฝึก!
การแบ่งส่วนวัตถุแต่ละชิ้นจากการอ้างอิงโดยไม่ต้องฝึกฝน
เทคโนโลยีล้ำสมัย (Papers with Code)
_SOTA 1-shot_ | -21CBCE?style=flat&logo=paperswithcode)
🚨 อัปเดต (5 กุมภาพันธ์ 2026): เอกสารฉบับร่างได้รับการอัปเดตด้วยการศึกษาผลกระทบเชิงลึก การแสดงภาพ และการทดลองเพิ่มเติม
🚨 อัปเดต (22 กรกฎาคม 2025): เพิ่มคำแนะนำสำหรับชุดข้อมูลที่กำหนดเองแล้ว!
🔔 อัปเดต (16 กรกฎาคม 2025): โค้ดได้รับการอัปเดตพร้อมคู่มือการใช้งานแล้ว!
📋 สารบัญ
- 🎯 ไฮไลท์
- 📜 บทคัดย่อ
- 🧠 สถาปัตยกรรม
- 🛠️ คำแนะนำการ forestall
- 1. โคลนรีโพสิทอรี
- 2. สร้างสภาพแวดล้อม conda
- 3. ติดตั้ง SAM2 และ DINOv2
- 4. ดาวน์โหลดชุดข้อมูล
- 5. ดาวน์โหลด checkpoint ของ SAM2 และ DINOv2
- 📊 โค้ดสำหรับ Inference: ทำซ้ำผล SOTA 30-shot ใน Few-shot COCO
- 0. สร้างชุดอ้างอิง
- 1. เติมข้อมูลอ้างอิงลงในหน่วยความจำ
- 2 personalized. ประมวลผลหน่วยความจำหลังจากเติม
- 3. Inference บนภาพเป้าหมาย
- ผลลัพธ์
- 🔍 ชุดข้อมูลกำหนดเอง
- 0. เตรียมชุดข้อมูลกำหนดเอง ⛵🐦
- 0.1 หากมีเฉพาะการกำกับ bbox
- 0.2 แปลง anotations coco เป็นไฟล์ pickle
- 1. เติมข้อมูลในหน่วยความจำด้วยตัวอย่างอ้างอิง
- 2. ประมวลผลหน่วยความจำภายหลัง
- 📚 การอ้างอิง
🎯 ไฮไลท์
- 💡 ไม่ต้องฝึกสอน (Training-Free): ไม่ต้องปรับจูน ไม่ต้องวิศวกรรมพรอมต์—แค่ใช้ภาพตัวอย่างอ้างอิง
- 🖼️ อ้างอิงภาพ (Reference-Based): แบ่งส่วนวัตถุใหม่โดยใช้เพียงตัวอย่างไม่กี่ภาพ
- 🔥 ประสิทธิภาพระดับ SOTA: มีประสิทธิภาพเหนือกว่าวิธีไม่ต้องฝึกสอนก่อนหน้าใน COCO, PASCAL VOC และ Cross-Domain FSOD
📜 บทคัดย่อ
The performance of image segmentation models has historically been constrained by the high cost of collecting large-scale annotated data. The Segment Anything Model (SAM) alleviates this original problem through a promptable, semantics-agnostic, segmentation paradigm and yet still requires manual visual-prompts or complex domain-dependent prompt-generation rules to process a new image. Towards reducing this new burden, our work investigates the task of object segmentation when provided with, alternatively, only a small set of reference images. Our key insight is to leverage strong semantic priors, as learned by foundation models, to identify corresponding regions between a reference and a target image. We find that correspondences enable automatic generation of instance-level segmentation masks for downstream tasks and instantiate our ideas via a multi-stage, training-free method incorporating (1) memory bank construction; (2) representation aggregation and (3) semantic-aware feature matching. Our experiments show significant improvements on segmentation metrics, leading to state-of-the-art performance on COCO FSOD (36.8% nAP), PASCAL VOC Few-Shot (71.2% nAP50) and outperforming existing training-free approaches on the Cross-Domain FSOD benchmark (22.4% nAP).
🧠 Architecture
🛠️ Installation instructions
1. Clone the repository
git clone https://github.com/miquel-espinosa/no-time-to-train.git
cd no-time-to-train
2. สร้างสภาพแวดล้อม conda
เราจะสร้างสภาพแวดล้อม conda พร้อมกับแพ็กเกจที่จำเป็น
conda env create -f environment.yml
conda activate no-time-to-train3. ติดตั้ง SAM2 และ DINOv2
เราจะติดตั้ง SAM2 และ DINOv2 จากซอร์ส
pip install -e .
cd dinov2
pip install -e .
cd ..4. ดาวน์โหลดชุดข้อมูล
กรุณาดาวน์โหลดชุดข้อมูล COCO และวางไว้ใน data/coco
5. ดาวน์โหลดไฟล์ตรวจสอบ SAM2 และ DINOv2
เราจะดาวน์โหลดไฟล์ตรวจสอบ SAM2 ที่ใช้ในบทความนี้โดยตรง (อย่างไรก็ตาม ไฟล์ตรวจสอบ SAM2.1 มีให้ดาวน์โหลดแล้ว และอาจให้ประสิทธิภาพที่ดีกว่า)
mkdir -p checkpoints/dinov2
cd checkpoints
wget https://dl.fbaipublicfiles.com/segment_anything_2/072824/sam2_hiera_large.pt
cd dinov2
wget https://dl.fbaipublicfiles.com/dinov2/dinov2_vitl14/dinov2_vitl14_pretrain.pth
cd ../..
📊 โค้ดสำหรับการอนุมาน
⚠️ ข้อสงวนสิทธิ์: นี่คือโค้ดสำหรับการวิจัย — อาจมีความยุ่งเหยิงบ้าง!
การทำซ้ำผลลัพธ์ SOTA แบบ 30 ตัวอย่างใน Few-shot COCO
กำหนดตัวแปรที่มีประโยชน์และสร้างโฟลเดอร์สำหรับผลลัพธ์:
CONFIG=./no_time_to_train/new_exps/coco_fewshot_10shot_Sam2L.yaml
CLASS_SPLIT="few_shot_classes"
RESULTS_DIR=work_dirs/few_shot_results
SHOTS=30
SEED=33
GPUS=4mkdir -p $RESULTS_DIR
FILENAME=few_shot_${SHOTS}shot_seed${SEED}.pkl
#### 0. สร้างชุดข้อมูลอ้างอิงpython no_time_to_train/dataset/few_shot_sampling.py \
--n-shot $SHOTS \
--out-path ${RESULTS_DIR}/${FILENAME} \
--seed $SEED \
--dataset $CLASS_SPLIT
#### 1. เติมหน่วยความจำด้วยการอ้างอิงpython run_lightening.py test --config $CONFIG \
--model.test_mode fill_memory \
--out_path ${RESULTS_DIR}/memory.ckpt \
--model.init_args.model_cfg.memory_bank_cfg.length $SHOTS \
--model.init_args.dataset_cfgs.fill_memory.memory_pkl ${RESULTS_DIR}/${FILENAME} \
--model.init_args.dataset_cfgs.fill_memory.memory_length $SHOTS \
--model.init_args.dataset_cfgs.fill_memory.class_split $CLASS_SPLIT \
--trainer.logger.save_dir ${RESULTS_DIR}/ \
--trainer.devices $GPUS
#### 2. ประมวลผลหน่วยความจำธนาคารหลังการประมวลผลpython run_lightening.py test --config $CONFIG \
--model.test_mode postprocess_memory \
--model.init_args.model_cfg.memory_bank_cfg.length $SHOTS \
--ckpt_path ${RESULTS_DIR}/memory.ckpt \
--out_path ${RESULTS_DIR}/memory_postprocessed.ckpt \
--trainer.devices 1
#### 3. การอนุมานบนภาพเป้าหมายpython run_lightening.py test --config $CONFIG \
--ckpt_path ${RESULTS_DIR}/memory_postprocessed.ckpt \
--model.init_args.test_mode test \
--model.init_args.model_cfg.memory_bank_cfg.length $SHOTS \
--model.init_args.model_cfg.dataset_name $CLASS_SPLIT \
--model.init_args.dataset_cfgs.test.class_split $CLASS_SPLIT \
--trainer.logger.save_dir ${RESULTS_DIR}/ \
--trainer.devices $GPUS
หากคุณต้องการดูผลการอนุมานแบบออนไลน์ (ขณะที่กำลังคำนวณ) ให้เพิ่มอาร์กิวเมนต์: --model.init_args.model_cfg.test.online_vis True
เพื่อปรับค่าเกณฑ์คะแนนพารามิเตอร์ score_thr ให้เพิ่มอาร์กิวเมนต์ (ตัวอย่างเช่น เพื่อแสดงผลอินสแตนซ์ทั้งหมดที่มีคะแนนสูงกว่า 0.4):
--model.init_args.model_cfg.test.vis_thr 0.4
ขณะนี้ภาพจะถูกบันทึกไว้ใน results_analysis/few_shot_classes/ ภาพทางซ้ายแสดงค่าความจริงพื้นฐาน ส่วนภาพทางขวาแสดงอินสแตนซ์ที่ถูกแบ่งส่วนซึ่งพบโดยวิธีที่ไม่ต้องฝึกสอนของเราโปรดทราบว่าในตัวอย่างนี้เราใช้ชุด few_shot_classes ดังนั้นเราควรคาดหวังว่าจะเห็นเฉพาะอินสแตนซ์ที่ถูกแบ่งส่วนของคลาสในชุดนี้ (ไม่ใช่ทุกคลาสใน COCO)
#### ผลลัพธ์
หลังจากรันภาพทั้งหมดในชุด validation คุณควรจะได้รับ:
BBOX RESULTS:
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.368SEGM RESULTS:
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.342
🔍 ชุดข้อมูลที่กำหนดเอง
เรามีคำแนะนำสำหรับการรัน pipeline ของเรากับชุดข้อมูลที่กำหนดเอง รูปแบบการกำกับข้อมูลจะต้องเป็นแบบ COCO เสมอ
โดยสรุป; หากต้องการดูวิธีการรัน pipeline แบบเต็มบน ชุดข้อมูลที่กำหนดเอง โดยตรง ให้ดูที่scripts/matching_cdfsod_pipeline.shพร้อมกับสคริปต์ตัวอย่างของชุดข้อมูล CD-FSOD (เช่นscripts/dior_fish.sh)
0. เตรียมชุดข้อมูลที่กำหนดเอง ⛵🐦
สมมติว่าเราต้องการตรวจจับ เรือ⛵ และ นก🐦 ในชุดข้อมูลที่กำหนดเอง เพื่อใช้วิธีการของเรา คุณจะต้องมี:
- อย่างน้อย 1 ภาพอ้างอิงที่ มีการกำกับข้อมูล สำหรับแต่ละคลาส (เช่น 1 ภาพอ้างอิงสำหรับเรือ และ 1 ภาพอ้างอิงสำหรับนก)
- ภาพเป้าหมายหลายภาพเพื่อค้นหาตัวอย่างของคลาสที่ต้องการ
mkdir -p data/my_custom_dataset
python scripts/make_custom_dataset.py
สิ่งนี้จะสร้างชุดข้อมูลที่กำหนดเองโดยมีโครงสร้างโฟลเดอร์ดังนี้:
data/my_custom_dataset/
├── annotations/
│ ├── custom_references.json
│ ├── custom_targets.json
│ └── references_visualisations/
│ ├── bird_1.jpg
│ └── boat_1.jpg
└── images/
├── 429819.jpg
├── 101435.jpg
└── (all target and reference images)
การแสดงผลภาพอ้างอิง (1-shot):| ภาพอ้างอิง 1-shot สำหรับ BIRD 🐦 | ภาพอ้างอิง 1-shot สำหรับ BOAT ⛵ |
|:---------------------------------:|:----------------------------------:|
| |
|
0.1 หากมีเฉพาะ annotation ประเภท bbox เท่านั้น
เรายังมีสคริปต์สำหรับสร้าง segmentation mask ระดับอินสแตนซ์โดยใช้ SAM2 ซึ่งจะมีประโยชน์หากคุณมี annotation เฉพาะ bounding box สำหรับภาพอ้างอิงเท่านั้น
# Download sam_h checkpoint. Feel free to use more recent checkpoints (note: code might need to be adapted)
wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth -O checkpoints/sam_vit_h_4b8939.pth
Run automatic instance segmentation from ground truth bounding boxes.
python no_time_to_train/dataset/sam_bbox_to_segm_batch.py \
--input_json data/my_custom_dataset/annotations/custom_references.json \
--image_dir data/my_custom_dataset/images \
--sam_checkpoint checkpoints/sam_vit_h_4b8939.pth \
--model_type vit_h \
--device cuda \
--batch_size 8 \
--visualize
ภาพอ้างอิงพร้อมมาสก์เซกเมนต์ระดับอินสแตนซ์ (สร้างโดย SAM2 จากกรอบบอกซ์จริง, 1-shot):ภาพแสดงผลของมาสก์เซกเมนต์ที่สร้างขึ้นถูกบันทึกไว้ใน data/my_custom_dataset/annotations/custom_references_with_SAM_segm/references_visualisations/
| ภาพอ้างอิง 1-shot สำหรับ BIRD 🐦 (เซกเมนต์โดยอัตโนมัติด้วย SAM) | ภาพอ้างอิง 1-shot สำหรับ BOAT ⛵ (เซกเมนต์โดยอัตโนมัติด้วย SAM) |
|:---------------------------------:|:----------------------------------:|
| |
|
0.2 แปลง annotation แบบ coco เป็นไฟล์ pickle
python no_time_to_train/dataset/coco_to_pkl.py \
data/my_custom_dataset/annotations/custom_references_with_segm.json \
data/my_custom_dataset/annotations/custom_references_with_segm.pkl \
1
1. เติมหน่วยความจำด้วยการอ้างอิง
ก่อนอื่น กำหนดตัวแปรที่จำเป็นและสร้างโฟลเดอร์สำหรับผลลัพธ์ เพื่อให้แสดงป้ายกำกับได้ถูกต้อง ชื่อคลาสควรเรียงตามรหัสหมวดหมู่ที่ปรากฏในไฟล์ json เช่น bird มีรหัสหมวดหมู่ 16, boat มีรหัสหมวดหมู่ 9 ดังนั้น CAT_NAMES=boat,bird
DATASET_NAME=my_custom_dataset
DATASET_PATH=data/my_custom_dataset
CAT_NAMES=boat,bird
CATEGORY_NUM=2
SHOT=1
YAML_PATH=no_time_to_train/pl_configs/matching_cdfsod_template.yaml
PATH_TO_SAVE_CKPTS=./tmp_ckpts/my_custom_dataset
mkdir -p $PATH_TO_SAVE_CKPTS
รันขั้นตอนที่ 1:python run_lightening.py test --config $YAML_PATH \
--model.test_mode fill_memory \
--out_path $PATH_TO_SAVE_CKPTS/$DATASET_NAME\_$SHOT\_refs_memory.pth \
--model.init_args.dataset_cfgs.fill_memory.root $DATASET_PATH/images \
--model.init_args.dataset_cfgs.fill_memory.json_file $DATASET_PATH/annotations/custom_references_with_segm.json \
--model.init_args.dataset_cfgs.fill_memory.memory_pkl $DATASET_PATH/annotations/custom_references_with_segm.pkl \
--model.init_args.dataset_cfgs.fill_memory.memory_length $SHOT \
--model.init_args.dataset_cfgs.fill_memory.cat_names $CAT_NAMES \
--model.init_args.model_cfg.dataset_name $DATASET_NAME \
--model.init_args.model_cfg.memory_bank_cfg.length $SHOT \
--model.init_args.model_cfg.memory_bank_cfg.category_num $CATEGORY_NUM \
--trainer.devices 1
2. หน่วยความจำแบงก์หลังการประมวลผล
python run_lightening.py test --config $YAML_PATH \
--model.test_mode postprocess_memory \
--ckpt_path $PATH_TO_SAVE_CKPTS/$DATASET_NAME\_$SHOT\_refs_memory.pth \
--out_path $PATH_TO_SAVE_CKPTS/$DATASET_NAME\_$SHOT\_refs_memory_postprocessed.pth \
--model.init_args.model_cfg.dataset_name $DATASET_NAME \
--model.init_args.model_cfg.memory_bank_cfg.length $SHOT \
--model.init_args.model_cfg.memory_bank_cfg.category_num $CATEGORY_NUM \
--trainer.devices 1#### 2.1 แสดงภาพหน่วยความจำที่ผ่านการประมวลผลแล้ว
python run_lightening.py test --config $YAML_PATH \
--model.test_mode vis_memory \
--ckpt_path $PATH_TO_SAVE_CKPTS/$DATASET_NAME\_$SHOT\_refs_memory_postprocessed.pth \
--model.init_args.dataset_cfgs.fill_memory.root $DATASET_PATH/images \
--model.init_args.dataset_cfgs.fill_memory.json_file $DATASET_PATH/annotations/custom_references_with_segm.json \
--model.init_args.dataset_cfgs.fill_memory.memory_pkl $DATASET_PATH/annotations/custom_references_with_segm.pkl \
--model.init_args.dataset_cfgs.fill_memory.memory_length $SHOT \
--model.init_args.dataset_cfgs.fill_memory.cat_names $CAT_NAMES \
--model.init_args.model_cfg.dataset_name $DATASET_NAME \
--model.init_args.model_cfg.memory_bank_cfg.length $SHOT \
--model.init_args.model_cfg.memory_bank_cfg.category_num $CATEGORY_NUM \
--trainer.devices 1
การแสดงผลภาพด้วย PCA และ K-means สำหรับภาพใน memory bank ถูกจัดเก็บไว้ที่ results_analysis/memory_vis/my_custom_dataset3. การอนุมานบนภาพเป้าหมาย
หากตั้งค่า ONLINE_VIS เป็น True ผลการทำนายจะถูกบันทึกไว้ใน results_analysis/my_custom_dataset/ และแสดงผลในขณะที่คำนวณ โปรดทราบว่าการรันด้วยการแสดงผลออนไลน์จะช้ากว่ามาก
คุณสามารถปรับเกณฑ์คะแนน VIS_THR เพื่อดูอินสแตนซ์ที่ถูกแบ่งส่วนมากขึ้นหรือน้อยลงได้ตามต้องการ
ONLINE_VIS=True
VIS_THR=0.4
python run_lightening.py test --config $YAML_PATH \
--model.test_mode test \
--ckpt_path $PATH_TO_SAVE_CKPTS/$DATASET_NAME\_$SHOT\_refs_memory_postprocessed.pth \
--model.init_args.model_cfg.dataset_name $DATASET_NAME \
--model.init_args.model_cfg.memory_bank_cfg.length $SHOT \
--model.init_args.model_cfg.memory_bank_cfg.category_num $CATEGORY_NUM \
--model.init_args.model_cfg.test.imgs_path $DATASET_PATH/images \
--model.init_args.model_cfg.test.online_vis $ONLINE_VIS \
--model.init_args.model_cfg.test.vis_thr $VIS_THR \
--model.init_args.dataset_cfgs.test.root $DATASET_PATH/images \
--model.init_args.dataset_cfgs.test.json_file $DATASET_PATH/annotations/custom_targets.json \
--model.init_args.dataset_cfgs.test.cat_names $CAT_NAMES \
--trainer.devices 1
ผลลัพธ์
ตัวชี้วัดประสิทธิภาพ (โดยใช้พารามิเตอร์เดียวกับคำสั่งด้านบน) ควรเป็นดังนี้:
BBOX RESULTS:
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.478SEGM RESULTS:
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.458
ผลลัพธ์เชิงภาพจะถูกบันทึกไว้ใน results_analysis/my_custom_dataset/ โปรดทราบว่าวิธีการของเราทำงานกับกรณี false negatives นั่นคือ รูปภาพที่ไม่มีวัตถุของคลาสที่ต้องการอยู่เลยคลิกที่รูปภาพเพื่อขยาย ⬇️
| รูปเป้าหมายที่มีเรือ ⛵ (ซ้าย GT, ขวาคือผลทำนาย) | รูปเป้าหมายที่มีนก 🐦 (ซ้าย GT, ขวาคือผลทำนาย) |
|:----------------------:|:----------------------:|
| |
|
| รูปเป้าหมายที่มีทั้งเรือและนก ⛵🐦 (ซ้าย GT, ขวาคือผลทำนาย) | รูปเป้าหมายที่ไม่มีเรือหรือนก 🚫 (ซ้าย GT, ขวาคือผลทำนาย) |
|:---------------------------------:|:----------------------------------:|
| |
|
🔬 การทดสอบแบบ ablation
การทดลองกับ backbone
เพื่อประเมินความสามารถในการถ่ายทอดของวิธีเราบน foundation models ต่าง ๆ เราได้เปลี่ยนทั้งตัวเข้ารหัสเชิงความหมาย (DINOv2) และ segmenter ที่ใช้ SAM กับทางเลือกอื่น ๆ หลายแบบ
การทดลองกับตัวเข้ารหัสเชิงความหมาย:
# CLIP (Sizes: b16, b32, l14, l14@336px)
bash scripts/clip/clipl14@336px.sh
bash scripts/clip/clipl14.sh
bash scripts/clip/clipb16.sh
bash scripts/clip/clipb32.shDINOV3 (Sizes: b, l, h)
bash scripts/dinov3/dinov3b.sh
bash scripts/dinov3/dinov3l.sh
bash scripts/dinov3/dinov3h.shPE (Sizes: g14, l14)
bash scripts/pe/PEg14.sh
bash scripts/pe/PEl14.shการทดลองตัดส่วน Segmenter:
# SAM2 (Sizes: tiny, small, base+, large)
bash scripts/sam2/sam2_tiny.sh
bash scripts/sam2/sam2_small.sh
bash scripts/sam2/sam2_base_plus.sh
bash scripts/baseline/dinov2_sam_baseline.sh # SAM2 Largeการประเมิน VLM บนชุดข้อมูล COCO แบบตัวอย่างน้อย
เราทำการประเมิน QWEN VLM บนชุดข้อมูล COCO แบบตัวอย่างน้อย
bash scripts/vl-qwen/ablation-vl-qwen.shฮิวริสติกของภาพอ้างอิง
เพื่อทำความเข้าใจว่าทำไมภาพอ้างอิงที่แตกต่างกันจึงนำไปสู่ความแปรปรวนของประสิทธิภาพ เราวิเคราะห์คุณสมบัติทางสถิติของการกำกับประเภทใหม่ใน sop COCO
#### การวิเคราะห์
เราศึกษาลักษณะของการกำกับสามประการ: (1) พื้นที่หน้ากาก (ขนาดวัตถุ), (2) ตำแหน่งศูนย์กลางของหน้ากาก, และ (3) ระยะห่างจากขอบภาพ
คำแนะนำ:
# Mask area distribution
python no_time_to_train/make_plots/mask_area_distribution.py \
--input data/coco/annotations/instances_val2017.json \
--output no_time_to_train/make_plots/mask_area_distribution/mask_area_distribution.png \
--edges-output no_time_to_train/make_plots/mask_area_distribution/bbox_edge_distance_histograms.png \
--center-output no_time_to_train/make_plots/mask_area_distribution/bbox_center_density.png \
--bins 80 \
--distance-bins 80 \
--disable-center-densityBbox center positions
python no_time_to_train/make_plots/bbox_positions.py \
--per-class-root data/coco/annotations/per_class_instances \
--filename centeredness_2d_hist_plain.png \
--max-cols 6 \
--output-dir ./no_time_to_train/make_plots/bbox_positions \
--outfile grid_bbox_positions.png
[OUTPUT] การกระจายพื้นที่ของหน้ากาก
[OUTPUT] ความหนาแน่นของจุดศูนย์กลาง Bbox
[OUTPUT] ฮิสโตแกรมระยะขอบของ Bbox
#### การเลือก
เราสุ่มตัวอย่างภาพอ้างอิงที่หลากหลาย 100 ภาพต่อคลาส โดยครอบคลุมช่วงของขนาดหน้ากาก ตำแหน่งศูนย์กลาง และระยะขอบอย่างชัดเจน แต่ละภาพอ้างอิงจะถูกประเมินบนชุดย่อยตรวจสอบที่ลดขนาดแบบคงที่
คำแนะนำ:
สคริปต์ติดตั้ง: scripts/1shot_ref_ablation/setup.sh:
- สร้างไฟล์ json ต่อคลาส
- วิเคราะห์คลาสเฉพาะ
- สร้างชุดข้อมูลอ้างอิงด้วยกลยุทธ์เชิงฮิวริสติกที่ต่างกัน
bash scripts/1shot_ref_ablation/setup.shรันสคริปต์: scripts/1shot_ref_ablation/gpu*.sh:
- รันไพป์ไลน์สำหรับแต่ละชุดอ้างอิง
# Example launch script that calls template script for each reference set
bash scripts/1shot_ref_ablation/gpu0.sh#### ผลลัพธ์
เราได้วิเคราะห์ว่า คะแนนการตรวจจับมีความสัมพันธ์กับลักษณะเฉพาะของภาพอ้างอิงอย่างไร (ขนาดหน้ากาก, ตำแหน่งศูนย์กลาง, ระยะห่างจากขอบภาพ)
คำแนะนำ:
python no_time_to_train/make_plots/heuristics_analysis.py
Outputs:
- no_time_to_train/make_plots/heuristics_analysis/heatmap_bbox_norm_scores.png
- no_time_to_train/make_plots/heuristics_analysis/heatmap_segm_norm_scores.png
- no_time_to_train/make_plots/heuristics_analysis/heatmap_center_bbox_norm_scores_kde_smooth.png
- no_time_to_train/make_plots/heuristics_analysis/heatmap_center_bbox_norm_scores.png
- no_time_to_train/make_plots/heuristics_analysis/heatmap_center_segm_norm_scores_kde_smooth.png
- no_time_to_train/make_plots/heuristics_analysis/heatmap_center_segm_norm_scores.png
- no_time_to_train/make_plots/heuristics_analysis/per_class_area_vs_raw_scores.png
- no_time_to_train/make_plots/heuristics_analysis/all_classes_area_vs_norm_scores.png
- no_time_to_train/make_plots/heuristics_analysis/edge_distance_vs_norm_scores.png
- no_time_to_train/make_plots/heuristics_analysis/bars_area_category_norm_scores.png
- no_time_to_train/make_plots/heuristics_analysis/bars_centered_norm_scores.png
- no_time_to_train/make_plots/heuristics_analysis/bars_avoid_sides_norm_scores.png
[OUTPUT] กราฟแท่ง. ผลของพื้นที่หน้ากาก (ซ้าย) และการจัดศูนย์ (ขวา) ต่อประสิทธิภาพ
[OUTPUT] ฮีทแมป. แผนที่คะแนน 2 มิติของประสิทธิภาพในฐานะฟังก์ชันของตำแหน่งศูนย์กลางหน้ากาก
[OUTPUT] ประสิทธิภาพภาพอ้างอิงเทียบกับพื้นที่หน้ากากสำหรับคลาสใหม่ COCO ทั้งหมด
การเสื่อมสภาพของภาพอ้างอิง
เราประเมินวิธีของเราภายใต้ภาพอ้างอิงที่เสื่อมสภาพอย่างต่อเนื่องโดยการเพิ่มระดับของ Gaussian blur
คำแนะนำ:
# Run different blur levels
bash scripts/blur_ablation/blur_ablation.shPlot grid of blur ablation results
python no_time_to_train/make_plots/plot_blur_results.py \
--results-root ./work_dirs/blur_ablation \
--class-id 0 \
--max-cols 4 \
--output-dir ./no_time_to_train/make_plots/blur_ablation \
--outfile grid_blur_ablation_class_0.pngความคล้ายคลึงของฟีเจอร์
สคริปต์สำหรับการแสดงภาพความคล้ายคลึงของฟีเจอร์ระหว่างภาพอ้างอิงและภาพเป้าหมาย
มันจะสร้างความคล้ายคลึงของฟีเจอร์เดียว (ฟีเจอร์เส้นทาง) และความคล้ายคลึงแบบต้นแบบ (ฟีเจอร์รวม)
คำแนะนำ:
python no_time_to_train/make_plots/feature_similarity.py \
--classes orange \
--num-images 20 \
--min-area 12 \
--max-area 25000 \
--min-instances 2 \
--seed 123 \
--max-per-class 12
แผนภาพ T-SNE (การแยกคุณสมบัติของ DINOv2)
t-SNE ของคุณสมบัติ DINOv2 แสดงการแยกที่ชัดเจนสำหรับคลาสที่แตกต่างกัน
แต่มีการทับซ้อนกันมากสำหรับคลาสที่คล้ายกัน ซึ่งบ่งชี้ว่าความสับสนเกิดจาก
รูปทรงของคุณสมบัติแบ็คโบนมากกว่าการเลือกต้นแบบ
คำแนะนำ:
ดึงคุณสมบัติ
python no_time_to_train/make_plots/tsne-coco.py --extractวาดกราฟ T-SNE
# Example spoon vs fork
python no_time_to_train/make_plots/tsne-coco.py --classes cat dog🛠️ ตัวช่วย
การแสดงภาพหน่วยความจำ
เพิ่มรูปภาพ feature_comparison_small.png ที่นี่
คำแนะนำ
เพื่อแสดงภาพหน่วยความจำ (การแสดงภาพด้วย PCA และ K-means) สำหรับการทดลองที่กำหนด ให้ปรับคำสั่งต่อไปนี้
ตั้งค่า DO_NOT_CROP เป็น True/False (ใน no_time_to_train/models/Sam2MatchingBaseline_noAMG.py) เพื่อแสดงภาพอ้างอิงพร้อม/โดยไม่ใช้หน้ากากที่ถูกครอบตัด
python run_lightening.py test --config $CONFIG \
--model.test_mode vis_memory \
--ckpt_path $RESULTS_DIR/memory_postprocessed.ckpt \
--model.init_args.dataset_cfgs.fill_memory.memory_pkl $RESULTS_DIR/$FILENAME \
--model.init_args.dataset_cfgs.fill_memory.memory_length $SHOT \
--model.init_args.dataset_cfgs.fill_memory.class_split $CLASS_SPLIT \
--model.init_args.model_cfg.dataset_name $CLASS_SPLIT \
--model.init_args.model_cfg.memory_bank_cfg.length $SHOT \
--model.init_args.model_cfg.memory_bank_cfg.category_num $CATEGORY_NUM \
--trainer.devices 1
ปรับขนาดภาพเป็น 512x512 (ทำให้ภาพเป็นสี่เหลี่ยมจัตุรัส)
เพื่อปรับขนาดภาพเป็น 512x512 และบันทึกลงในไดเรกทอรีใหม่ ให้รันคำสั่งต่อไปนี้ ซึ่งใช้สำหรับรูปภาพในเอกสาร
คำแนะนำ:
python no_time_to_train/make_plots/paper_fig_square_imgs.py
ขนาดโมเดลและหน่วยความจำ
ในการคำนวณขนาดโมเดลและหน่วยความจำ ให้รันคำสั่งต่อไปนี้
คำแนะนำ:
- ดู
no_time_to_train/models/Sam2MatchingBaseline_noAMG_model_and_memory.pyสำหรับการคำนวณขนาดโมเดลและหน่วยความจำ
🌍 ชุดข้อมูล EO
สคริปต์ประเมินผล (ชุดข้อมูล EO)
สามารถพบสคริปต์ประเมินผลได้ในไดเรกทอรี scripts/EO ชุดข้อมูล EO ใช้สคริปต์ ./scripts/EO/EO_template.sh เพื่อรันการประเมินผล
แต่ละการรันทดลอง EO จะถูกบันทึกไว้ภายใต้ไดเรกทอรี ./EO_results ในโฟลเดอร์ทดลองเราจะจัดเก็บ:
- ไฟล์ summary.txt ที่มีค่าคอนฟิกและเวลาการทำงานของการทดลอง
- การแสดงผลการทำนายบนชุดทดสอบ (โฟลเดอร์
results_analysis) - การแสดงผลการใช้หน่วยความจำ (
memory_visโฟลเดอร์) - ไฟล์พิกเกิลการอนุมัติแบบ few-shot
- เช็คพอยต์ของโมเดล (หากไม่ได้ลบออก)
รูปภาพและตาราง
สคริปต์เพิ่มเติมสำหรับสร้างรูปภาพและตารางตาราง latex สรุปของชุดข้อมูล EO:
python scripts/convert_datasets/summary_table_datasets.py
สร้างตาราง LaTeX ของชุดข้อมูล EO:
python scripts/paper_figures/table_EO_results.py ./EO_results_no_heuristics
กราฟความแม่นยำของชุดข้อมูล EO:
python scripts/paper_figures/plot_EO_accuracy.py \
--input-root ./EO_results \
--output-root ./EO_resultsสรุปผลของฮิวริสติกที่มีต่อชุดข้อมูล EO:
python scripts/paper_figures/plot_EO_heuristic.py \
--no-heuristics ./EO_results_no_heuristics \
--heuristics ./EO_resultsกราฟแสดงเวลาในการทำงานของชุดข้อมูล EO:
python scripts/paper_figures/plot_EO_runtime.py \
--input-root ./EO_results \
--output-root ./EO_resultsสร้างภาพการแสดงผลตาราง EO สำหรับรูปในเอกสาร:
python scripts/paper_figures/plot_EO_grid.py \
--root ./EO_results_no_heuristics \
--dataset ISAID \
--shots 1📚 Citation
If you use this work, please cite us:
@article{espinosa2025notimetotrain,
title={No time to train! Training-Free Reference-Based Instance Segmentation},
author={Miguel Espinosa and Chenhongyi Yang and Linus Ericsson and Steven McDonagh and Elliot J. Crowley},
journal={arXiv preprint arXiv:2507.02798},
year={2025},
primaryclass={cs.CV}
}--- Tranlated By Open Ai Tx | Last indexed: 2026-03-13 ---