ZACK777 commited on
Commit
381e146
·
verified ·
1 Parent(s): 617d016

Document PETA Stage A/B results for fixed hyperbolic lift

Browse files
Files changed (1) hide show
  1. README.md +60 -56
README.md CHANGED
@@ -10,83 +10,87 @@ tags:
10
  - clip
11
  - promptpar
12
  - hi-mapper
 
13
  pipeline_tag: feature-extraction
14
  ---
15
 
16
- # HI-Mapper (code only)
17
 
18
- Hyperbolic hierarchy mapper for pedestrian attribute recognition (PromptPAR).
19
- This Hub repo contains **source code only** — **no trained weights**.
 
20
 
21
- HI-Mapper lifts Euclidean region / CLIP features into the Lorentz hyperboloid,
22
- builds a fixed depth-3 anatomical tree, and supervises it with entailment cones,
23
- sibling separation, and radius ordering (MERU / HyCoCLIP style). An optional
24
- attribute-grounded entailment term maps PETA-style attribute prefixes onto tree
25
- nodes. An optional HypDAE-style hyperbolic diffusion decoder is included.
26
 
27
- ## Contents
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  ```
30
  hi_mapper/
31
- __init__.py # public exports
32
- lorentz.py # Lorentz manifold + EuclideanToLorentz lift
33
- tree.py # hierarchical / attribute entailment losses
34
- hi_mapper.py # DivHiMapper + PETA attr grouping
35
- hyp_diffusion.py # optional hyperbolic diffusion decoder
36
- ARCHITECTURE.md # detailed architecture notes
37
  ```
38
 
39
- ## Install
40
 
41
- ```bash
42
- pip install torch
43
- # then copy hi_mapper/ into your project, or:
44
- git clone https://huggingface.co/ZACK777/hi-mapper
45
- ```
46
 
47
- Requires PyTorch. No Hub weights are downloaded.
48
 
49
- ## Quick start
 
 
 
 
 
 
 
50
 
51
- ```python
52
- import torch
53
- from hi_mapper import DivHiMapper, build_attr_groups
54
-
55
- # region tokens: [B, 5, D] = global + 4 anatomical leaves
56
- B, D = 2, 768
57
- region_tokens = torch.randn(B, 5, D)
58
- cls = torch.randn(B, D)
59
-
60
- mapper = DivHiMapper(
61
- feat_dim=D,
62
- curvature=0.2,
63
- target_radius=1.0,
64
- attr_groups=None, # or build_attr_groups(attr_names)
65
- )
66
- root, mid, leaves, hier_loss, prompt_loss, attr_loss = mapper(
67
- region_tokens, cls
68
- )
69
- ```
70
 
71
- ## Geometry notes
 
 
 
 
72
 
73
- - `EuclideanToLorentz` uses a running-norm scaler (not LayerNorm) so relative
74
- norms — and thus hyperbolic radii — stay meaningful.
75
- - Distance uses a numerically stable `asinh` form; Minkowski products run in
76
- float64 intermediates.
77
- - Entailment uses half-aperture / exterior-angle cones (`K=0.1`).
78
 
79
- ## Integration
80
 
81
- Designed as a drop-in branch for PromptPAR / CLIP-based PAR models. See
82
- `hi_mapper/ARCHITECTURE.md` for the tree layout, losses, and optional decoder.
83
 
84
- ## Citation / context
85
 
86
- Built for hyperbolic hierarchical regularisation on top of PromptPAR-style
87
- region tokens. Related ideas: MERU, HyCoCLIP, HypDAE, Khrulkov et al. (δ-hyperbolicity).
 
 
 
 
 
 
 
 
 
88
 
89
  ## License
90
 
91
- Apache-2.0 (code). Upstream PromptPAR / CLIP licenses still apply if you use
92
- those backbones.
 
10
  - clip
11
  - promptpar
12
  - hi-mapper
13
+ - vit
14
  pipeline_tag: feature-extraction
15
  ---
16
 
17
+ # HI-Mapper — PromptPAR hyperbolic branch
18
 
19
+ Hyperbolic hierarchy mapper for PromptPAR, with the **fixed Euclidean → Lorentz lift**
20
+ (running-norm scaler, stable distance, entailment cones). This repo includes
21
+ **source code** plus the **two ViT weights PromptPAR needs to run**.
22
 
23
+ ## Weights
 
 
 
 
24
 
25
+ | File | Role | Size |
26
+ |------|------|------|
27
+ | `weights/ViT-L-14.pt` | OpenAI CLIP ViT-L/14 (PromptPAR backbone) | ~890 MB |
28
+ | `weights/jx_vit_base_p16_224-80ecf9dd.pth` | ImageNet ViT-B/16 (MM-former blocks init) | ~331 MB |
29
+
30
+ ```bash
31
+ hf download ZACK777/hi-mapper --local-dir ./hi-mapper
32
+ # then point PromptPAR at:
33
+ # .cache/clip/ViT-L-14.pt ← copy from weights/ViT-L-14.pt
34
+ # jx_vit_base_p16_224-80ecf9dd.pth ← copy from weights/
35
+ ```
36
+
37
+ ## Code
38
 
39
  ```
40
  hi_mapper/
41
+ lorentz.py # Lorentz manifold + EuclideanToLorentz
42
+ tree.py # entailment / sibling / radius losses
43
+ hi_mapper.py # DivHiMapper + PETA attr grouping
44
+ hyp_diffusion.py
 
 
45
  ```
46
 
47
+ ## PETA results (new Euclidean→hyperbolic lift)
48
 
49
+ Dataset: **PETA**, PromptPAR flags: `--use_textprompt --use_div --use_vismask --use_GL --use_mm_former`.
50
+ HI-Mapper default: `c=0.2`, `hi_mapper_w=0.1`, warmup 3 epochs, `--use_attr_hierarchy`.
 
 
 
51
 
52
+ ### Stage A — 1-epoch do-no-harm gate
53
 
54
+ | Config | epoch-1 mA | Acc | F1 | notes |
55
+ |--------|------------|-----|-----|-------|
56
+ | **A_control** (no HI-Mapper) | 0.6102 | 0.4972 | 0.6412 | baseline |
57
+ | A_default (HI-Mapper) | **0.6375** | 0.5059 | 0.6492 | +2.7 pts vs control |
58
+ | A_attr | 0.6375 | 0.5059 | 0.6492 | same as default (attr on) |
59
+ | A_r15 (`hyp_target_radius=1.5`) | **0.6406** | 0.4981 | 0.6407 | best epoch-1 |
60
+ | A_prompt | 0.6345 | 0.5050 | 0.6483 | |
61
+ | A_w030 (`hi_mapper_w=0.3`) | 0.6286 | 0.4894 | 0.6339 | |
62
 
63
+ All HI-Mapper configs beat the no-HI-Mapper control at epoch 1 (old broken lift was ~0.615 and *below* historical baseline).
64
+
65
+ ### Stage B — compressed 15-epoch (partial: epochs 1–3 before interrupt)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
+ | Epoch | Control mA | HI-Mapper mA | HI-Mapper Acc | HI-Mapper F1 | `hi_mapper_loss` (epoch avg) |
68
+ |-------|------------|--------------|---------------|--------------|------------------------------|
69
+ | 1 | 0.6102 | **0.6175** | 0.5139 | 0.6578 | 1.720 |
70
+ | 2 | 0.6337 | **0.6720** | 0.5288 | 0.6677 | 1.029 |
71
+ | 3 | 0.6943 | **0.6997** | 0.5634 | 0.6957 | **0.187** |
72
 
73
+ Key signal vs the old broken lift: hierarchical loss no longer floors at ~0.20 from epoch 1; it falls **1.72 → 0.19** by epoch 3 while mA stays ahead of the matched control.
 
 
 
 
74
 
75
+ > Full 15-epoch Stage B and 100-epoch final runs were interrupted; re-launch to complete the table.
76
 
77
+ ### Reference (published PromptPAR, PETA)
 
78
 
79
+ mA **88.76** / Acc **82.84** / F1 **89.18** (TCSVT 2024) — requires full 100-epoch cosine schedule.
80
 
81
+ ## Quick start
82
+
83
+ ```python
84
+ import torch
85
+ from hi_mapper import DivHiMapper
86
+
87
+ mapper = DivHiMapper(feat_dim=768, curvature=0.2, target_radius=1.0)
88
+ root, mid, leaves, hier_loss, prompt_loss, attr_loss = mapper(
89
+ torch.randn(2, 5, 768), torch.randn(2, 768)
90
+ )
91
+ ```
92
 
93
  ## License
94
 
95
+ Apache-2.0 for HI-Mapper code. CLIP / ViT checkpoints retain their original licenses
96
+ (OpenAI CLIP; Google / timm ImageNet ViT-B/16).