SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Xudong Wang $^{1*}$  Shufan Li $^{1*}$  Konstantinos Kallidromitis $^{2*}$
Yusuke Kato $^{2}$  Kazuki Kozuka $^{2}$  Trevor Darrell $^{1}$
<sup>1</sup>Berkeley AI Research, UC Berkeley 2Panasonic AI Research
project page: http://people.eecs.berkeley.edu/\~xdwang/projects/HIPIE
Open-vocabulary image segmentation aims to partition an image into semantic regions according to arbitrary text descriptions. However, complex visual scenes can be naturally decomposed into simpler parts and abstracted at multiple levels of granularity, introducing inherent segmentation ambiguity. Unlike existing methods that typically sidestep this ambiguity and treat it as an external factor, our approach actively incorporates a hierarchical representation encompassing different semantic-levels into the learning process. We also propose a decoupled text-image fusion mechanism and representation learning modules for both "things" and "stuff". Additionally, we systematically examine the differences that exist in the textual and visual features between these types of categories. Our resulting model, named HIPIE, tackles HHierarchical, oPen-vocabulary, and unIvErsal segmentation tasks within a unified framework. Benchmarked on over 40 datasets, e.g., ADE20K, COCO, Pascal-VOC Part, RefCOCO/RefCOCOg, ODinW and SeginW, HIPIE achieves the state-of-the-art results at various levels of image comprehension, including semantic-level (e.g., semantic segmentation), instance-level (e.g., panoptic/referring segmentation and object detection), as well as part-level (e.g., part/subpart segmentation) tasks.
Image segmentation is a fundamental task in computer vision, enabling a wide range of applications such as object recognition, scene understanding, and image manipulation [50, 14, 42, 7, 37]. Recent advancements in large language models pave the way for open-vocabulary image segmentation, where models can handle a wide variety of object classes using text prompts. However, there is no single "correct" way to segment an image. The inherent ambiguity in segmentation stems from the fact that the interpretations of boundaries and regions within an image depend on the specific tasks.
Existing methods for open-vocabulary image segmentation typically address the ambiguity in image segmentation by considering it as an external factor beyond the modeling process. In contrast, we adopt a different approach by embracing this ambiguity and present HPIE, as illustrated in Fig. 1, a novel Hierarchical, oPen-vocabulary and unIvErsal image segmentation and detection model. This includes semantic-level segmentation, which focuses on segmenting objects based on their semantic meaning, as well as instance-level segmentation, which involves segmenting individual instances of objects or groups of objects (e.g., instance and referring segmentation).
<sup>1</sup>The terms things (countable objects, typically foreground) and stuff (non-object, non-countable, typically background) [1] are commonly used to distinguish between objects that have a well-defined geometry and are countable, e.g. people, cars, and animals, and surfaces or regions that lack a fixed geometry and are primarily identified by their texture and/or material, e.g. the sky, road, and water body.
*: equal contribution
Figure 1: HIPIE is a unified framework which, given an image and a set of arbitrary text descriptions, provides hierarchical semantic, instance, part, and subpart-level image segmentations. This includes open-vocabulary semantic (e.g., crowds and sky), instance/panoptic (e.g., person and cat), part (e.g., head and torso), subpart (e.g., ear and nose) and referring expression (e.g., umbrella with a white pole) masks. HIPIE outperforms previous methods and established new SOTAs on these tasks regardless of their granularity or task specificity. Bottom images: our method can seamlessly integrate with SAM to enable class-aware image segmentation on SA-1B.
Additionally, our model captures finer details by incorporating part-level segmentation, which involves segmenting object parts/subparts. By encompassing different granularity, HIPIE allows for a more comprehensive and nuanced analysis of images, enabling a richer understanding of their contents.
To design HIPIE, we begin by investigating the design choices for open-vocabulary image segmentation (OIS). Existing methods on OIS typically adopt a text-image fusion mechanism, and employ a shared representation learning module for both stuff and thing classes [4, 62, 58, 10, 56]. Fig. 2 shows the similarity matrices of visual and textual features between stuff and thing classes. On this basis, we can derive several conclusions:
- Noticeable discrepancies exist in the between-class similarities of textual and visual features between stuff and thing classes.
- Stuff classes exhibit significantly higher levels of similarity in text features than things.
Figure 2: Noticeable discrepancies exist in the between-class similarities of visual and textual features between stuff and thing classes. We propose a decoupled representation learning approach that effectively generates more discriminative visual and textual features. We extract similarity matrices for the visual features, obtained through a pretrained MAE [17] or our fine-tuned one, and for the text features, produced using a pretrained BERT [6] or fine-tuned one. We report results on COCO-Panoptic [23] and measure the mean similarity  $(\mu)$ .
Open Vocab.	Instance Segment.	Semantic Segment.	Panoptic Segment.	Referring Segment.	Cls-agnostic Part Seg.	Cls-aware Part Seg.	Object Detection
SAM [24]	X	✓	X	X	X	✓	X	*
SEEM [67]	✓	✓	✓	✓	✓	X	X	*
ODISE [56]	✓	✓	✓	✓	X	X	X	*
UNINEXT [58]	†	✓	X	X	✓	X	X	✓
X-Decoder [66]	✓	✓	✓	✓	✓	X	X	*
G-DINO [36]	✓	✓	X	X	✓	X	X	✓
PPS [5]	X	X	X	X	X	✓	✓	X
HIPIE	✓	✓	✓	✓	✓	✓	✓	✓
vs. prev. SOTA	-	+5.1	+2.0	+1.3	+0.5	-	+5.2	+3.2
Table 1: Our HIPIE is capable of performing all the listed segmentation and detection tasks and achieves the state-of-the-art performance using a unified framework. We present performance comparisons with SOTA methods on a range of benchmark datasets:  $\mathrm{AP^{mask}}$  for instance segmentation on MSCOCO [34],  $\mathrm{AP^{box}}$  for object detection on MSCOCO, oIoU for referring segmentation on RefCOCO+ [61], mIoU for semantic segmentation on Pascal Context[64], and mIoUPartS for part segmentation on Pascal-Panoptic-Parts [5]. The second best performing method for each task is underlined.  $*$ : object detection can be conducted via generating bounding boxes using instance segmentation masks. 'Seg.' denotes segmentation.  $\dagger$ : In principle, UNINEXT can take arbitrary texts as labels, however, the original work focused on close-set performance and did not explore open-vocabulary inference.
This observation suggests that integrating textual features may yield more significant benefits in generating discriminative features for thing classes compared to stuff classes. Consequently, for thing classes, we adopt an early image-text fusion approach to fully leverage the benefits of discriminative textual features. Conversely, for stuff classes, we utilize a late image-text fusion strategy to mitigate the potential negative effects introduced by non-discriminative textual features. Furthermore, the presence of discrepancies in the visual and textual features between stuff and thing classes, along with the inherent differences in their characteristics (stuff classes requiring better capture of texture and materials, while thing classes often having well-defined geometry and requiring better capture of shape information), indicates the need for decoupling the representation learning modules for producing masks for stuffs and things.
In addition to instance/semantic-level segmentation, our model is capable of open-vocabulary hierarchical segmentation. Instead of treating part classes, like 'dog leg', as standard multi-word labels, we concatenate class names from different granularity as prompts. During training, we supervise the classification head using both part labels, such as 'tail', and instance labels, such as 'dog', and we explicitly contrast a mask embedding with both instance-level and part-level labels. In the inference stage, we perform two separate forward passes using the same image but different prompts to generate instance and part segmentation. This design choice empowers open-vocabulary hierarchical segmentation, allowing us to perform part segmentation on novel part classes by randomly combining classes from various granularity, such as 'giraffe' and 'leg', even if they have never been seen during training. By eliminating the constraints of predefined object classes and granularity, HIPIE offers a more flexible and adaptable solution for image segmentation.
We extensively benchmark HIPIE on various popular datasets to validate its effectiveness, including MSCOCO, ADE20K, Pascal Panoptic Part, and RefCOCO/RefCOCOg. HIPIE achieves state-of-the-art performance across all these datasets that cover a variety of tasks and granularity.
To the best of our knowledge, HIPIE is the first hierarchical, open-vocabulary and universal image segmentation and detection model (see Table 1). By decoupling representation learning and text-image fusion mechanisms for things vs. stuff classes, HIPIE overcomes the limitations of existing approaches and achieves state-of-the-art performance on various benchmarks.
Open-Vocabulary Semantic Segmentation [2, 53, 26, 16, 44, 32, 54, 55] aims to segment an image into semantic regions indicated by text descriptions that may not have been seen during training. ZS3Net [2] combines a deep visual segmentation model with an approach to generate
visual representations from semantic word embeddings to learn pixel-wise classifiers for novel categories. LSeg [26] uses CLIP's text encoder [43] to generate the corresponding semantic class's text embedding, which it then aligns with the pixel embeddings. OpenSeg [16] adopts a grouping strategy for pixels prior to learning visual-semantic alignments. By aligning each word in a caption to one or a few predicted masks, it can scale-up the dataset and vocabulary sizes. GroupViT [54] is trained on a large-scale image-text dataset using contrastive losses. With text supervision alone, the model learns to group semantic regions together. OVSegmentor [55] uses learnable group tokens to cluster image pixels, aligning them with the corresponding caption embeddings.
Open-Vocabulary Panoptic Segmentation (OPS) unifies semantic and instance segmentation, and aims to perform these two tasks for arbitrary categories of text-based descriptions during inference time [10, 56, 66, 67, 58]. MaskCLIP [10] first predicts class-agnostic masks using a mask proposal network. Then, it refines the mask features through Relative Mask Attention interactions with the CLIP visual model and integrates the CLIP text embeddings for open-vocabulary classification. ODISE [56] unifies Stable Diffusion [47], a pre-trained text-image diffusion model, with text-image discriminative models, e.g. CLIP [43], to perform open-vocabulary panoptic segmentation. X-Decoder [66] takes two types of queries as input: generic non-semantic queries that aim to decode segmentation masks for universal segmentation, and textual queries to make the decoder language-aware for various open-vocabulary vision tasks. UNINEXT [58] unifies diverse instance perception tasks into an object discovery and retrieval paradigm, enabling flexible perception of open-vocabulary objects by changing the input prompts.
Referring Segmentation learns valid multimodal features between visual and linguistic modalities to segment the target object described by a given natural language expression [19, 60, 20, 22, 13, 59, 52, 35, 63]. It can be divided into two main categories: 1) Decoder-fusion based method [8, 51, 63, 35] first extracts vision features and language features, respectively, and then fuses them with a multimodal design. 2) Encoder-fusion based method [13, 59, 30] fuses the language features into the vision features early in the vision encoder.
Parts Segmentation learns to segment instances into more fine-grained masks. PPP [5] established a baseline of hierarchical understanding of images by combining a scene-level panoptic segmentation model and part-level segmentation model. JPPF [21] improved this baseline by introducing joint Panoptic-Part Fusion module that achieves comparable performance with significantly smaller models.
Promptable Segmentation. The Segment Anything Model (SAM) [24] is an approach for building a fully automatic promptable image segmentation model that can incorporate various types of human interventions, such as texts, masks, and points. SEEM [67] proposes a unified prompting scheme that encodes user intents into prompts in a joint visual-semantic space. This approach enables SEEM to generalize to unseen prompts for segmentation, achieving open-vocabulary and zero-shot capabilities. Referring segmentation can also be considered as promptable segmentation with text prompts.
Comparison with Previous Work. Table 1 compares our HIPIE method with previous work in terms of key properties. Notably, HIPIE is the only method that supports open-vocabulary universal image segmentation and detection, enabling the object detection, instance-, semantic-, panoptic-, hierarchical-(whole instance, part, subpart), and referring-segmentation tasks, all within a single unified framework.
We consider all relevant tasks under the unified framework of language-guided segmentation, which performs open-vocabulary segmentation and detection tasks for arbitrary text-based descriptions.
The proposed HIPIE model comprises three main components, as illustrated in Fig. 3:
1) Text-image feature extraction and information fusion (detailed in Secs. 3.2 to 3.4): We first generate a text prompt  $T$  from labels or referring expressions. Then, we extract image  $(I)$  and text  $(T)$  features  $F_{v} = \operatorname{Enc}_{v}(I), F_{t} = \operatorname{Enc}_{t}(T)$  using image encoder  $\operatorname{Enc}_{v}$  and text encoder  $\operatorname{Enc}_{t}$ , respectively. We then perform feature fusion and obtain fused features  $F_{v}', F_{t}' = \text{FeatureFusion}(F_{v}, F_{t})$ .
Figure 3: Diagram of HIPIE for hierarchical, universal and open-vocabulary image segmentation and detection. The image and text prompts are first passed to the image and text decoder to obtain visual features  $F_{v}$  and text features  $F_{t}$ . Early fusion is then applied to merge image and text features to get  $F_{v}^{\prime}, F_{t}^{\prime}$ . Two independent decoders are used for things (foreground) classes and stuff (background) classes.
2) Foreground (referred to as things) and background (referred to as stuffs) mask generation (detailed in Sec. 3.5): Each of the decoders takes in a set of image features and text features and returns sets of masks, bounding boxes, and object embeddings  $(M,B,E)$ . We compute the foreground and background proposals and concatenate them to obtain the final proposals and masks as follows:
Stuff:  $(M_2, B_2, E_2) = \text{StuffDecoder}(F_v, F_t)$
Thing:  $(M_1,B_1,E_1) =$  ThingDecoder(FeatureFusion  $(F_{v},F_{t})$  ） (1)
Overall:  $(M, B, E) = (M_1 \oplus M_2, B_1 \oplus B_2, E_1 \oplus E_2)$
where  $\oplus$  denotes the concatenation operation.
3) Proposal and mask retrieval using text prompts (detailed in Sec. 3.6): To assign class labels to these proposals, we compute the cosine similarity between object embedding  $E$  and the corresponding embedding  $E_{i}^{\prime}$  of class  $i \in \{1,2\ldots ,c\}$ . For a set of category names, the expression is a concatenated string containing all categories. We obtain  $E_{i}^{\prime}$  by pooling tokens corresponding to each label from the encoded sequence  $F_{t}$ . For referring expressions, we taken the [CLS] token from BERT output as  $E_{i}^{\prime}$ .
3.2 Text Prompts
Text prompting is a common approach used in open-vocabulary segmentation models [19, 60, 57, 58].
For open-vocabulary instance segmentation, panoptic segmentation, and semantic segmentation, the set of all labels  $C$  is concatenated into a single text prompt  $T_{i}$  using a “.” delimiter. Given an image  $I$  and a set of text prompts  $T$ , the model aims to classify  $N$  masks in the label space  $C \cup \{“other”\}$ , where  $N$  is the maximum number of mask proposals generated by the model.
For referring expressions, the text prompt is simply the sentence itself. The goal is to locate one mask in the image corresponding to the language expression.
3.3 Image and Text Feature Extraction
We employ a pretrained BERT model [6] to extract features for text prompts. Because the BERT-base model can only process input sequences up to 512 tokens, we divide longer sequences into segments of 512 tokens and encode each segment individually. The resulting features are then concatenated to obtain features of the original sequence length.
We utilize ResNet-50 [18] and Vision Transformer (ViT) [11] as base architectures for image encoding. In the case of ResNet-50, we extract multiscale features from the last three blocks and denote them as  $F_{v}$ . For ViT, we use the output features from blocks 8, 16, and 32 as the multiscale features  $F_{v}$ .
Figure 4: Various design choices for generating thing and stuff masks with arbitrary text descriptions. In version a), We use a single decoder for all masks. Early fusion is applied. In version b), two independent decoders are used for things and stuff classes. Early fusion is adopted for both decoders. Version c) is identical to version b) with the only difference being that the stuff decoder do not make use of early fusion.
3.4 Text-Image Feature Fusion
We explored several design choices for text-image feature fusion and mask generation modules as shown in Fig. 4 and Table 5, and discovered that Fig. 4c) can give us the optimal performance. We adopt bi-directional cross-attention (Bi-Xattn) to extract text-guided visual features  $F_{t2v}$  and image-guided text features  $F_{v2t}$ . These attentive features are then integrated with the vanilla text features  $F_t$  and image features  $F_v$  through residual connections, as shown below:
$$
\begin{array}{r c l} F _ {t 2 v}, F _ {v 2 t} & = & \operatorname {B i - X a t t n} \left(F _ {v}, F _ {t}\right) \\ \left(F _ {v} ^ {\prime}, F _ {t} ^ {\prime}\right) & = & \left(F _ {v} + F _ {t 2 v}, F _ {t} + F _ {v 2 t}\right) \end{array} \tag {2}
$$
where  $F_{v}$  and  $F_{t}$  represent the visual and text-prompt features, respectively.
3.5 Thing and Stuff Mask Generation
We then generate masks and proposals for the thing and stuff classes by utilizing  $F_v'$  and  $F_t'$  that we obtained in Sec. 3.4.
Model Architecture. While architectures such as Mask2Former and MaskDINO [4, 28] can perform instance, semantic and panoptic segmentation simultaneously, models trained jointly show inferior performance compared with the same model trained for a specific task (e.g. instance segmentation only). We hypothesize that this may result from the different distribution of spatial location and geometry of foreground instance masks and background semantic masks. For example, instance masks are more likely to be connected, convex shapes constrained by a bounding box, whereas semantic masks may be disjoint, irregular shapes spanning across the whole image.
To address this issue, in a stark contrast to previous approaches [58, 36, 57] that use a unified decoder all both stuffs and things, we decouple the stuff and thing mask prediction using two separate decoders. For the thing decoder, we adopt Deformable DETR [65] with a mask head following the UNINEXT [58] architecture and incorporate denoising procedures proposed by DINO [62]. For the stuff decoder, we use the architecture of MaskDINO [28].
Proposal and Ground-Truth Matching Mechanisms. We make the following distinctions between the two heads. For thing decoder, we adopt simOTA [15] to perform many-to-one matching between box proposals and ground truth when calculating the loss. We also use box-iou-based NMS to remove duplicate predictions. For the stuff decoder, we adopt one-to-one Hungarian matching [25]. Additionally, we disable the box loss for stuff masks. We set the number of queries to 900 for the things and 300 for the stuffs.
Loss Functions. For both decoders, we calculate the class logits as the normalized dot product between mask embeddings  $(M)$  and text embeddings  $(F_t')$ . We adopt Focal Loss [33] for classification outputs, L1 loss, and GIoU loss [45] for box predictions, pixel-wise binary classification loss and DICE loss [49] for mask predictions. Given predictions  $(M_1, B_1, E_1), (M_2, B_2, E_2)$ , groundtruth labels  $(M', B', C)$  and its foreground and background subset  $(M_f', B_f', C_f)$  and  $(M_b', B_b', C_b)$ , The final Loss is computed as
$$
\begin{array}{l} \mathcal {L} _ {\text {t h i n g}} = \lambda_ {\operatorname {c l s}} \mathcal {L} _ {\operatorname {c l s}} \left(E _ {1}, C _ {f} ^ {\prime}\right) + \lambda_ {\operatorname {m a s k}} \mathcal {L} _ {\operatorname {m a s k}} \left(M _ {1}, M _ {f} ^ {\prime}\right) + \lambda_ {\operatorname {b o x}} \mathcal {L} _ {\operatorname {b o x}} \left(B _ {1}, B _ {f} ^ {\prime}\right) \\ \mathcal {L} _ {\text {s t u f f}} = \lambda_ {\mathrm {c l s}} \mathcal {L} _ {\mathrm {c l s}} \left(E _ {2}, C ^ {\prime}\right) + \lambda_ {\text {m a s k}} \mathcal {L} _ {\text {m a s k}} \left(M _ {2}, M ^ {\prime}\right) + \lambda_ {\text {b o x}} \mathcal {L} _ {\text {b o x}} \left(B _ {2}, B _ {b} ^ {\prime}\right) \tag {3} \\ \mathcal {L} \quad = \mathcal {L} _ {\text {t h i n g}} + \mathcal {L} _ {\text {s t u f f}} \\ \end{array}
$$
where  $\mathcal{L}_{\mathrm{box}} = \lambda_{L1}\mathcal{L}_{L1} + \lambda_{\mathrm{giou}}\mathcal{L}_{\mathrm{giou}}$ ,  $\mathcal{L}_{\mathrm{mask}} = \lambda_{\mathrm{ce}}\mathcal{L}_{\mathrm{ce}} + \lambda_{\mathrm{dice}}\mathcal{L}_{\mathrm{dice}}$ , and  $\mathcal{L}_{\mathrm{cls}} = \mathcal{L}_{\mathrm{focal}}$ . Note that while we do not use the stuff decoder for thing prediction, we still match its predictions with things and
Figure 5: Hierarchical segmentation pipeline. We concatenate the instance class names and part class names as labels. During the training process, we supervise the classification head using both part labels and instance labels. During inference, we perform two separate forward passes using the same image but different prompts to generate instance and part segmentations. By combining the part segmentation and instance segmentation of the same image, we obtain hierarchical segmentation results on the right side.
compute the class and box losses in the training. We find such auxiliary loss setup make the stuff decoder aware of the thing distribution and imporves the final performance.
3.6 Open-Vocabulary Universal Segmentation
In closed set setting, we simply merge the output of two decoders and perform the standard postprocessing of UNINEXT [58] and MaskDINO [28] to obtain the final output.
In zero-shot open vocabulary setting, we follow ODISE [56] and combining our classification logits with a text-image discriminative model, e.g., CLIP [43]. Specially, given the a mask  $M$  on image  $I$ , its features  $E$  and test classes  $C_{\mathrm{test}}$ , we first compute the probability  $p_1(E,C_{\mathrm{test}}) = \mathbb{P}(C_{\mathrm{test}}|E)$  in the standard way as mentioned before. We additionally compute mask-pooled features of  $M$  from the vision encoder  $\mathcal{V}$  of CLIP as  $E_{\mathrm{CLIP}} = \mathrm{MaskPooling}(M,\mathcal{V}(I))$ . Then we compute the CLIP logits  $p_2(E,C_{\mathrm{test}}) = \mathbb{P}(C_{\mathrm{test}}|E_{\mathrm{CLIP}})$  as the similarity between the CLIP text features and the  $E_{\mathrm{CLIP}}$ . Finally we combine the final prediction as
$$
p _ {\text {f i n a l}} (E, C _ {\text {t e s t}}) \propto p _ {1} (E, C _ {\text {t e s t}}) ^ {\lambda} p _ {2} (E, C _ {\text {t e s t}}) ^ {1 - \lambda} \tag {4}
$$
Where  $\lambda$  is a balancing factor. Empirically, we found such setting leads to better performance than naively relying completely on CLIP features only or close-set logits.
3.7 Hierarchical segmentation