Skip to content

About

PACO version of PartCatSeg modified to speed up annotations for parts

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fine-Grained Image-Text Correspondence with
Cost Aggregation for Open-Vocabulary Part Segmentation

Jiho Choi1 *, Seonho Lee1 *, Seungho Lee2, Minhyun Lee2, Hyunjung Shim1
(* indicates equal contributions)
1Graduate School of Artificial Intelligence, KAIST, Republic of Korea
2School of Integrated Technology, Yonsei University, Republic of Korea
{jihochoi, glanceyes, kateshim}@kaist.ac.kr, {seungholee, lmh315}@yonsei.ac.kr

arXiv CVPR

drawing


PartCATSeg

PartCATSeg is a novel framework to address the critical challenges of OVPS(Open-Vocabulary Part Segmentation) and significantly improve model performance by leveraging the cost volume.

drawing

Updates

  • [2025.04.15] 👨‍💻 The official codes have been released!
  • [2025.02.26] 🎉 Our paper has been accepted to CVPR 2025!
  • [2025.01.16] 📄 Our paper is now available! You can find the paper here.

Installation

# ------------------
#     Init conda
# ------------------
conda create --name partcatseg python=3.8 -y
conda activate partcatseg
pip install --upgrade pip
conda install cuda=12.4.1 -c nvidia -y
pip install torch==2.2.2 torchvision==0.17.2 --index-url https://download.pytorch.org/whl/cu121
pip install timm==0.9.1
pip install scikit-image==0.21.0
pip install scikit-learn==0.24.2
pip install opencv-python==4.5.5.64
pip install hydra-core==1.3.2
pip install openmim==0.3.6
pip install mmsegmentation==0.29.1
pip install tokenizers==0.11.1
pip install Pillow~=9.5
pip install numpy==1.23.0
pip install einops ftfy regex fire ninja psutil gdown

# --------------------------
#     Install Detectron2
# --------------------------
pip install 'git+https://github.com/facebookresearch/detectron2.git'
python -c "import detectron2; print(detectron2.__version__)"  # 0.6

# --------------------------
#     Install mmcv
# --------------------------
# pip install mmcv-full==1.7.1
# => if an error occurs
pip install mmcv-full==1.7.1 -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7.0/index.html
python -c "import mmcv; print(mmcv.__version__)"  # 1.7.1

Prepare Datasets

cd datasets

PascalPart116

  • You can find further information in the OV-PARTS GitHub repository.
gdown https://drive.google.com/uc?id=1QF0BglrcC0teKqx15vP8qJNakGgCWaEH
tar -xzf PascalPart116.tar.gz
find ./PascalPart116/images/val/ -name '._*' -delete
find ./PascalPart116/ -name '._*' -delete

ADE20KPart234

gdown https://drive.google.com/uc?id=1EBVPW_tqzBOQ_DC6yLcouyxR7WrctRKi
tar -xzf ADE20KPart234.tar.gz

PartImageNet (Seg)

  • Download the LOC_synset_mapping.txt file from this link and place it in the datasets folder.
  • Download PartImageNet_Seg from PartImageNet and extract it into the datasets folder as PartImageNet.

PartImageNet (OOD)

  • Download PartImageNet_OOD from PartImageNet and place it into the datasets folder as PartImageNet_OOD.

Preprocess Datasets

  • PascalPart116
  • ADE20KPart234
  • PartImageNet (Seg)
  • PartImageNet (OOD)
# PascalPart116
python baselines/data/datasets/mask_cls_collect.py \
    datasets/PascalPart116/annotations_detectron2_part/val \
    datasets/PascalPart116/annotations_detectron2_part/val_part_label_count.json

python baselines/data/datasets/mask_cls_collect.py \
    datasets/PascalPart116/annotations_detectron2_obj/val \
    datasets/PascalPart116/annotations_detectron2_part/val_obj_label_count.json

# ADE20KPart234
# (no preprocessing required)

# PartImageNet (Seg)
cd datasets
python partimagenet_preprocess.py --data_dir PartImageNet
# Make sure to have LOC_synset_mapping.txt in the datasets folder mentioned above.

# PartImageNet (OOD)
# train split
find PartImageNet_OOD/images/train/* -type f -exec mv {} PartImageNet_OOD/images/train/ \;
find PartImageNet_OOD/images/train/* -type d -empty -delete

# val split
find PartImageNet_OOD/images/val/* -type f -exec mv {} PartImageNet_OOD/images/val/ \;
find PartImageNet_OOD/images/val/* -type d -empty -delete

Pre-trained Weights

Please first donwload the pre-trained CAT-Seg weight model_final_base.pth from the following link to use them in the training.

Model Checkpoint
CAT-Seg download link

Make sure to place the downloaded weights in the pretrain_weights folder.

mkdir pretrain_weights && cd pretrain_weights
# CAT-Seg
wget https://huggingface.co/hamacojr/CAT-Seg/resolve/main/model_final_base.pth
cd ..

For the evaluation, we provide the pre-trained weights for the PartCATSeg model on the following datasets:

Model Setting Dataset Checkpoint
PartCATSeg zero-shot Pascal-Part-116 model
PartCATSeg zero-shot ADE20K-Part-234 model
PartCATSeg zero-shot PartImageNet (Seg) model
mkdir weights && cd weights

# Pascal-Part-116
# PartCATSeg (partcatseg_voc.pth (928M on Ubuntu / 885M on Google Drive))
gdown https://drive.google.com/uc?id=1JUJjJQLMKE96H5SLNs4EMm4jiU6fPgRb

# ADE20K-Part-234
# PartCATSeg (partcatseg_ade.pth (928M on Ubuntu / 885M on Google Drive))
gdown https://drive.google.com/uc?id=1MKQEk71o9Xvs4aBY_GLyGa1lWTaW10fv

# PartImageNet (Seg)
# PartCATSeg (partcatseg_partimagenet_seg.pth)
gdown https://drive.google.com/uc\?id\=1zvV6achGzDS_tAwulaSkFYblMTghMHO6

Usage (Run)

Zero-Shot Prediction
# -------------
#     Train
# -------------
python train_net.py \
    --num-gpus 4 \
    --config-file configs/zero_shot/partcatseg_voc.yaml

# -----------------
#     Inference
# -----------------
python train_net.py \
    --num-gpus 4 \
    --config-file configs/zero_shot/partcatseg_voc.yaml \
    --eval-only MODEL.WEIGHTS ./weights/partcatseg_voc.pth

Please note that the performance on PartImageNet_OOD should be evaluated by the metric 'mIoU-unbase' since the validation set of PartImageNet_OOD does not contain the base classes.



This fork: tabletop parts (PACO) and GraspClutter6D

This fork adds training on PACO-LVIS restricted to 39 tabletop objects / 197 object-part classes (bottle, box, can, cup, mug, jar, bowl, plate, knife, scissors, drill, ...), and per-object part segmentation of GraspClutter6D scenes using either its ground-truth masks or SAM 3 masks.

Environment (pixi)

This fork uses pixi instead of the conda/pip steps above. The env is locked in pixi.toml / pixi.lock (torch 2.2.2 + CUDA 12.1, detectron2 built against it).

source ./pixi_setup.sh      # keeps pixi's caches inside the repo; source it before every pixi command
pixi install
pixi run fetch-dinov2       # once: pins DINOv2's torch.hub code to the release-era commit
  • Set DETECTRON2_DATASETS in pixi.toml ([activation.env]) to your datasets root.
  • Don't pip install into this env. Add packages with pixi add / pixi add --pypi; a PyPI torch would break detectron2's compiled extension.
  • fetch-dinov2 is required because DINOv2's current main needs Python >= 3.10.

Train on PACO tabletop

1. Download PACO. This fetches the annotations and only the ~57.6k COCO images PACO uses (~9 GB), not the full COCO zips. It is resumable: re-run it until it prints ALL DONE.

bash datasets/paco_download.sh $DETECTRON2_DATASETS

2. Convert to PartCATSeg's object-part format (~30 s, CPU). This writes $DETECTRON2_DATASETS/PACO_tabletop/. The tabletop object list is the TABLETOP dict in the script; to change it, edit the dict and re-run.

pixi run python datasets/paco_tabletop_preprocess.py \
    --paco-ann  $DETECTRON2_DATASETS/PACO/annotations \
    --coco-root $DETECTRON2_DATASETS/coco \
    --out       $DETECTRON2_DATASETS/PACO_tabletop

The output contains absolute paths, so re-run the conversion if you move the data.

3. Train and test. Training fine-tunes from weights/partcatseg_ade.pth (download it as described in Pre-trained Weights) and evaluates on PACO val every 1k iterations. model_final.pth is then scored on PACO test.

bash train_paco.sh                                                        # full run: 20k iterations
OUT=output/paco_smoke bash train_paco.sh SOLVER.MAX_ITER 20 TEST.EVAL_PERIOD 0   # smoke test
config configs/zero_shot/partcatseg_paco_tabletop.yaml
output output/partcatseg_paco_tabletop/ (checkpoint every 1k iterations; log.txt, metrics.json)
batch 1 image x 4 gradient-accumulation steps (SOLVER.ACCUM_STEPS), equal to the paper's 4 GPUs x 1 image
cost on one RTX 4090 16 GB peak, ~1.2 s/step, ~7 h for 20k steps, plus ~11 min per val pass
  • Resuming: re-running train_paco.sh resumes from $OUT/last_checkpoint.
  • Overrides: trailing KEY VALUE pairs are detectron2 config overrides.
  • Shared GPU: the script refuses to start while another process holds the GPU; FORCE=1 overrides this.
  • Progress: follow tail -f output/partcatseg_paco_tabletop/log.txt. Training is done when model_final.pth exists and the PACO test result is printed.
  • Metric: every class is trained on (there is no zero-shot split), so read mIoU-base.

Part segmentation on GraspClutter6D

PartCATSeg was trained and evaluated conditioned on a given object mask, so it never learned object boundaries or background. Run on a whole image, it labels almost every pixel, including the table. Run it per object instead: give it one mask per object, and it labels only the pixels inside each mask.

Recommended: run_part_seg.sh. Edit the block at the top of the script, then run bash run_part_seg.sh.

MODE=both                                    # gt | sam3 | both
SCENE_DIR=/path/to/GraspClutter6D-2/scenes/000000
FRAME=000001
IMAGE=$SCENE_DIR/rgb/$FRAME.png              # any image works for sam3
GT_MASKS="$SCENE_DIR/mask_visib/${FRAME}_*.png"
WEIGHTS=output/partcatseg_paco_tabletop/model_final.pth
OBJ_CLASSES=datasets/gc6d_obj_classes.json   # gt: obj_id -> object class; empty = the model predicts it
SAM3_PROMPTS=(item)                          # concrete singular nouns ("objects" finds nothing)
# SAM3_PROMPTS=(pitcher=mug box can bottle)  # 'prompt=class': each mask gets its prompt's class
EXTRA_ARGS=()                                # e.g. (--min-score 0.1 --crop-margin 0.25)
SOM_PYTHON=/path/to/env-with-sam3/bin/python
HF_CACHE=/path/to/huggingface/cache          # must contain facebook/sam3

The two mask sources:

  • gt uses GraspClutter6D's visible-object masks (mask_visib/<frame>_*.png).
  • sam3 first detects objects with SAM 3 (export_sam3_masks.py), then segments parts inside them. This works on any image, not just GraspClutter6D.
    • SAM 3 needs transformers>=5, which this env cannot have, so it runs with a separate python (SOM_PYTHON).
    • The weights (facebook/sam3) are gated on Hugging Face: request access, then download them once into HF_CACHE.
    • Masks under 2000 px, or larger than 15 % of the image (the tote), are dropped.
    • With several SAM3_PROMPTS, SAM 3 runs once per prompt and each mask gets that prompt's class (pitcher=mug searches for "pitcher" but uses PACO's "mug" parts). Overlapping masks from different prompts keep only the highest-scoring one. The generic item prompt has no class, so the model predicts it.

Results go to results/<scene>/:

file content
<frame>_paco_<masks>_parts.png overlay with part names
<frame>_paco_<masks>_objects.png object class per mask
<frame>_paco_<masks>_labels.png uint16 part label map; 65535 = no part
<frame>_paco_<masks>_parts.json classes, object scores and top-3 per mask
<frame>_<masks>_comparison.png input next to the result
sam3_masks/<frame>_sam3_*.png the SAM 3 masks (sam3 mode), plus <frame>_sam3_classes.json

<masks> is mask_visib (GT) or sam3_masks, followed by _given when the object classes came from OBJ_CLASSES or the prompts rather than from the model. A frame with 16 objects takes ~15 s once the weights are cached.

Calling infer_image.py directly:

S=/path/to/GraspClutter6D-2/scenes/000000

# per object, GT masks and given object classes (recommended)
pixi run python infer_image.py $S/rgb/000001.png --obj-masks $S/mask_visib/000001_*.png \
    --obj-classes datasets/gc6d_obj_classes.json

# whole image, dropping weak labels (fast, but boundaries are coarse and the table gets labels)
pixi run python infer_image.py $S/rgb/000001.png --min-score 0.05

# another checkpoint, or a zero-shot vocabulary of "<object>'s <part>" names
pixi run python infer_image.py <img> --weights output/partcatseg_paco_tabletop/model_0009999.pth
pixi run python infer_image.py <img> --vocab "mug's handle" "mug's body" "kettle's spout"

Per-object mode crops a square around each mask (--crop-margin, default 0.15) and resizes it to 384² (--crop-size, the training crop size). It then picks the object class the model scores highest inside the mask, or takes it from --obj-classes, and keeps only that object's parts.

Give the object class whenever you can. The model's own object choice is the weak point:

  • Object scores are often only 0.06–0.2. On GraspClutter6D scenes 000000 and 000003 the model's top choice was wrong for 6 of 27 masks (boxes as book / carton, a can as frying pan, the drill as plate, the spoon as bowl), and two instances of the same object can get different classes.
  • A wrong object class picks the wrong part vocabulary, so every part in that mask is wrong. With the class given, the parts are mostly sensible (mug body / handle, bottle body / cap, plate rim / inner wall, spoon bowl / handle, drill body / handle).
  • --obj-classes takes a JSON keyed by mask file name or GraspClutter6D obj_id; null or an unknown name falls back to the model.
    • datasets/gc6d_obj_classes.json names the objects of scenes 000000 and 000003 (GC6D ships no object names). Extend it as you use new scenes.
    • Objects with no PACO class (strawberry, spring clamp, wooden block) are left out; the model then picks something close (the clamp comes out as scissors).
  • --objects mug bottle ... restricts the model's own choice to the objects you list.

Parts + materials (PartMaterialCATSeg)

PartMaterialCATSeg (baselines/partmaterialcatseg.py) adds a per-pixel, open-vocabulary material output to PartCATSeg.

The material branch is a fourth cost-aggregation pathway, next to the existing part+object, object and object-specific-part ones:

  1. CLIP image features are correlated with CLIP text embeddings of material names ("metal", "opaque plastic", ...).
  2. The result is refined by its own aggregator layers, guided by DINOv2 features, and decoded to material logits.
  3. The branch shares the CLIP / DINOv2 features and the guidance projections with the part branches.
  4. It is initialised as a copy of the trained part/object aggregator of the checkpoint it starts from.
  5. Material names are plain CLIP text, so the vocabulary can be swapped at test time.

Training data. No dataset has both part and material labels, so training mixes two:

dataset what it supervises images
PACO tabletop parts and objects 21k
DMS (Dense Material Segmentation) 52 materials 22k

Each image is tagged with its task, and only that task's losses are applied: PACO images get PartCATSeg's unchanged part/object losses, DMS images get a BCE loss on the material branch. A DMS image must never reach the part loss, because with no object labels every pixel would be taught as background. The part code (PartCATSeg) is subclassed, not edited.

1. Convert DMS (CPU, ~2 min). Its images are read where they are; only remapped labels are written, to $DETECTRON2_DATASETS/DMS_material/.

DMS dumps that are a flat folder of images/ + labels/ have lost their train/val/test split. split_ids.json restores DMS's original split (22,492 / 9,412 / 9,492). The converter drops the one train pair whose label is rotated against its image (25262), leaving 22,491. It is fetched from the image_id column of the Hugging Face copy, a few MB, using Material_Seg_AppleDMS/dataset_helpers/fetch_split_ids.py --repo_id AllanK24/apple-dms-materials.

pixi run python datasets/dms_material_preprocess.py \
    --dms-root /path/to/Dense-Material-Segmentation \
    --split-ids $DETECTRON2_DATASETS/DMS_material/split_ids.json \
    --out $DETECTRON2_DATASETS/DMS_material

2. Train and test. This fine-tunes the PACO model (output/partcatseg_paco_tabletop/model_final.pth). It evaluates every 5k iterations on PACO val (parts) and on 1,000 DMS val images (materials). At the end it scores PACO test and DMS test.

bash train_partmaterial.sh                                                        # 20k iterations
OUT=output/pm_smoke bash train_partmaterial.sh SOLVER.MAX_ITER 20 TEST.EVAL_PERIOD 0   # smoke test
config configs/zero_shot/partmaterialcatseg_paco_dms.yaml
output output/partmaterialcatseg_paco_dms/ (log.txt shows loss_sem_seg and loss_material)
cost on one RTX 4090 16 GB peak, ~0.75 s per step of 4 images, ~4–5 h for 20k steps, plus evaluation
metrics parts: mIoU-base (as for PACO); materials: material_seg/mIoU, mAcc, pAcc and per-class IoU (inference/material_*.json)

train_partmaterial.sh resumes, refuses a busy GPU and takes config overrides, like train_paco.sh. SKIP_TEST=1 skips the final test-set pass.

A progress bar shows steps done out of 20k, speed, time left and the current losses, e.g. train: 12%|█▏ | 2400/20000 [30:12<3:41:05, 1.32step/s, material=0.0127, sem_seg=0.0186]. It applies to every config trained with train_net.py (including train_paco.sh); PROGRESS_BAR False turns it off. It covers training steps only: evaluation passes report their own progress in the log.

Total time for a full run is ~6.5 h on a free 4090:

step time
training, 20k steps ~4.2 h
four evaluations at 5k / 10k / 15k / 20k (PACO val ~12.5 min + DMS val_1k ~2.7 min each) ~1 h
held-out losses every 1k iterations ~10 min
final test: PACO test (6,092 objects, ~49 min) + DMS test (9,492 images, ~25 min) ~1.25 h

Loss curves and over-fitting. Every 1,000 iterations, ValLossHook (train_net.py) computes the training losses on a fixed held-out set, 200 PACO val + 200 DMS val images, and logs them as val_loss_sem_seg / val_loss_material in metrics.json. The config keys are TEST.VAL_LOSS_PERIOD, VAL_LOSS_DATASETS and VAL_LOSS_IMAGES.

Plot a run, finished or still running:

pixi run python plot_training.py output/partmaterialcatseg_paco_dms    # -> <run>/training_curves.png

How to read the plot:

  • Over-fitting: the held-out loss flattens and then rises while the train loss keeps falling, and validation mIoU peaks and then drops.
  • Converged: the held-out loss and mIoU flatten.

The PACO-only run is an example of converged, not over-fitting: PACO val mIoU-base climbs from 30.1 at 1k to a best of 44.95 at 17k, then stays at ~44.

Material prompt templates (ablation). By default, material names are encoded with CLIP's 80 ImageNet templates, the ones PartCATSeg uses for parts. Those were written for objects, so some read oddly for materials ("a photo of many opaque plastic.").

configs/zero_shot/partmaterialcatseg_paco_dms_mattmpl.yaml uses 80 material-specific templates instead (baselines/third_party/material_templates.py: "a photo of something made of {}.", "the texture of {}.", …). Everything else is identical. The option is MODEL.MATERIAL.PROMPT_TEMPLATES "material"; the default "" keeps the ImageNet templates. There must be 80 templates, because conv_material has one input channel per template and is initialised from the part branch's conv1.

CFG=configs/zero_shot/partmaterialcatseg_paco_dms_mattmpl.yaml bash train_partmaterial.sh   # -> output/partmaterialcatseg_paco_dms_mattmpl
pixi run python infer_part_material.py <dir> --config configs/zero_shot/partmaterialcatseg_paco_dms_mattmpl.yaml \
    --weights output/partmaterialcatseg_paco_dms_mattmpl/model_final.pth

A checkpoint must be used with the config it was trained with: its weights expect its templates' text embeddings.

Zero-shot, before any training, the two template sets give the same raw cost volume quality on 300 DMS val images: mIoU 12.0 (ImageNet) vs 11.5 (material), pixel accuracy 28.6 for both (docs/partmaterial/compare_templates.py). A large gain from the trained ablation is therefore unlikely; it only remains to be measured.

3. Run on a directory of images. Results go to results/part_material/<dir name>/ by default.

pixi run python infer_part_material.py /path/to/images/                     # every image in the folder
pixi run python infer_part_material.py /path/to/images/ --objects mug bottle can box --min-score 0.1
pixi run python infer_part_material.py img.png --material-vocab metal "opaque plastic" glass cardboard wood
pixi run python infer_part_material.py /path/to/images/ --weights output/partmaterialcatseg_paco_dms/model_0009999.pth
file content
<stem>_panel.png 2×2: input, parts, materials, parts labelled with their material
<stem>_parts.png / _material.png part / material overlays
<stem>_part_material.png each part region named <part>: <majority material>
<stem>_parts_labels.png / _material_labels.png uint16 label maps; 65535 = none
<stem>.json material pixel shares, and per part its majority material and full material mix

By default this script runs on whole images, so parts have the problem described in Part segmentation on GraspClutter6D: the part head labels most pixels, background included, unless --min-score (default 0.1) or --objects limits it, and the whole-image material map is coarse enough that small objects take the material of the bin around them.

Per-object mode fixes both, with one mask per object:

pixi run python infer_part_material.py /path/to/images/ --sam3                  # SAM 3 masks, prompt "item"
pixi run python infer_part_material.py /path/to/images/ --sam3 --sam3-prompts pitcher=mug box can bottle
pixi run python infer_part_material.py $S/rgb/000001.png --masks-dir $S/mask_visib   # GC6D GT masks

Each object is cropped, and both heads run on the crop. Parts are conditioned on the object class: predicted, or given by --obj-classes or by multi-prompt SAM 3. Only pixels inside a mask are labelled. --sam3 runs export_sam3_masks.py in SegObjectMaterial's env (SAM 3 needs transformers 5) and caches the masks in <output dir>/sam3_masks/, which later runs reuse (--sam3-redo recomputes them). Output names gain _sam3_masks / _mask_visib, plus <stem>_..._objects.png labelling each mask <object>: <majority material>. On 4 GC6D frames it takes ~95 s in total, SAM 3 included.

Meeting figure. viz_part_material_report.py <output dir> turns a per-object run into one 16:9 PNG per image in <output dir>/report/. On the left is the scene, every part filled with its own material (part boundaries in dark lines, objects outlined in white and numbered), with a material legend. On the right is one card per object (same numbers): its crop with the parts coloured, and a "part - material" legend. Material colours are shared by every image in the directory. It is CPU only and reads the saved label maps, never the model. --alpha sets the fill opacity (default 0.7).


HOPS (AFM + AEM)

HOPS (CVPR 2026, Hierarchical Open-vocabulary Part Segmentation with Attention-Aware Filtering and Affinity-Guided Enhancement) is a fork of PartCATSeg. It is ported here as the meta-architecture Hops (baselines/hops.py) with head HopsHead, its own cost-aggregation model (baselines/modeling/transformer/hops_{model,predictor}.py) and evaluator (baselines/evaluation/hops_evaluation.py). It is two-stage: stage 1 segments objects (CLIP cost volume refined by CLIP self-attention, the AFM); each predicted object is then cropped, re-encoded by CLIP + DINOv2 and segmented into its parts (stage 2). PartCATSeg and the other models are unchanged: the shared CLIP and DINOv2 code only gained opt-in arguments, and their defaults were verified to give bit-identical outputs.

It starts from the CAT-Seg base weights, which are not in this checkout:

mkdir -p pretrain_weights
wget https://huggingface.co/hamacojr/CAT-Seg/resolve/main/model_final_base.pth -O pretrain_weights/model_final_base.pth
# smoke test: 20 iterations, no evaluation
pixi run python train_net.py --num-gpus 1 --config-file configs/zero_shot/hops_voc.yaml \
    SOLVER.MAX_ITER 20 TEST.EVAL_PERIOD 0 OUTPUT_DIR output/hops_smoke

# train + evaluate (Pascal-Part-116 / ADE20K-Part-234 / PartImageNet)
pixi run python train_net.py --num-gpus 1 --config-file configs/zero_shot/hops_voc.yaml
pixi run python train_net.py --num-gpus 1 --config-file configs/zero_shot/hops_ade.yaml
pixi run python train_net.py --num-gpus 1 --config-file configs/zero_shot/hops_partimagenet.yaml

# evaluate a checkpoint
pixi run python train_net.py --num-gpus 1 --config-file configs/zero_shot/hops_voc.yaml \
    --eval-only MODEL.WEIGHTS output/hops_voc/model_final.pth

HOPS released a config for PartImageNet only (batch 2); hops_voc.yaml and hops_ade.yaml mirror partcatseg_{voc,ade}.yaml with HOPS's model settings. All three run one image per pass and accumulate gradients (SOLVER.ACCUM_STEPS): 4 for VOC / ADE (PartCATSeg's batch), 2 for PartImageNet (HOPS's batch).

The released code differs from the paper in ways that were kept on purpose (reproduce first, change later; each is commented in the code):

  • AEM never runs. In training forward_second(..., part_in_my_obj, AEM) passes AEM = 1 positionally into the AEM_A argument, so AEM stays False; at test AEM=False is explicit.
  • The CLIP + DINOv2 fused attention (AFM_A) is computed and then not used; the AFM uses the CLIP attention alone. Since no output depends on it, the DINOv2 attention is skipped unless MODEL.HOPS.COMPUTE_AFM_A True.
  • HOPS's CLIP applies its last block twice for dense features (forward_dense, then the full block again). This comes from their edit of model_vpt.py and affects every CLIP image encoding in HOPS. It is reproduced through hops_compat=True, which only Hops passes.
  • In the aggregator, the layers are not chained (only the last layer's output is used), and the stage-2 stack layers_part starts from random init. Several modules are never used.
  • The JSD loss is defined but not used. Stage-2 crops come from the model's own object prediction, also during training.
  • The evaluator uses a different protocol than PartCATSeg's. It scores the prediction without GT object conditioning, with background as an extra class in the mIoU. Its result keys are pred_with_gt / pred_without_gt. Its OSI metric hard-codes Pascal and ADE part-to-object tables, so osi-* and mOSI are meaningless on PartImageNet. Do not compare HOPS numbers with PartCATSeg's oracle_obj numbers directly.

Project Structure

[PROJECT_ROOT]
├── datasets/
│   ├── PascalPart116/
│   │   ├── images
│   │   ├── annotations_detectron2_obj
│   │   └── annotations_detectron2_part
│   ├── ADE20KPart234/
│   ├── PartImageNet/
│   └── PartImageNet_OOD/
│       ├── images
│       │   ├── annotations_detectron2_part
│       │   └── annotations_detectron2_part
│       ├── train.json
│       └── val.json
├── weights/
│   ├── partcatseg_voc.pth
│   └── partcatseg_ade.pth
├── configs/
│   ├── zero_shot
│   │   ├── partcatseg_voc.yaml
│   │   ├── partcatseg_ade.yaml
│   │   ├── partcatseg_partimagenet.yaml
│   │   ├── partcatseg_partimagenet_ood.yaml
│   │   └── ...
├── baselines/
│   ├── evaluation/
│   │   └── partcatseg_evaluation.py
│   ├── data/
│   │   ├── dataset_mappers/
│   │   │   └── object_part_mapper.py
│   │   └── datasets/
│   │       └── register_pascal_part_116.py
│   ├── modeling/
│   │   ├── backbone/
│   │   │   └── dinov2_backbone.py
│   │   ├── heads/
│   │   │   └── part_cat_seg_head.py
│   │   └── transformer/
│   │       ├── part_cat_seg_model.py
│   │       ├── part_cat_seg_predictor.py
│   │       └── part_cat_seg_model.py
│   ├── utils/
│   │   └── visualizer.py
│   ├── third_party/
│   ├── partcatseg.py
│   └── config.py
├── README.md
└── train_net.py

Acknowledgement

We would like to express our gratitude to the open-source projects and their contributors, including PartCLIPSeg, OV-PARTS, CLIPSeg, Mask2Former, CLIP, and OV-DETR.

About

PACO version of PartCatSeg modified to speed up annotations for parts

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages