Open-World Entity Segmentation

Overview

Open-World Entity Segmentation Project Website

Lu Qi*, Jason Kuen*, Yi Wang, Jiuxiang Gu, Hengshuang Zhao, Zhe Lin, Philip Torr, Jiaya Jia


This project provides an implementation for the paper "Open-World Entity Segmentation" based on Detectron2. Entity Segmentation is a segmentation task with the aim to segment everything in an image into semantically-meaningful regions without considering any category labels. Our entity segmentation models can perform exceptionally well in a cross-dataset setting where we use only COCO as the training dataset but we test the model on images from other datasets at inference time. Please refer to project website for more details and visualizations.


Installation

This project is based on Detectron2, which can be constructed as follows.

  • Install Detectron2 following the instructions. We are noting that our code is implemented in detectron2 commit version 28174e932c534f841195f02184dc67b941c65a67 and pytorch 1.8.
  • Setup the coco dataset including instance and panoptic annotations following the structure. The code of entity evaluation metric is saved in the file of modified_cocoapi. You can directly replace your compiled coco.py with modified_cocoapi/PythonAPI/pycocotools/coco.py.
  • Copy this project to /path/to/detectron2/projects/EntitySeg
  • Set the "find_unused_parameters=True" in distributed training of your own detectron2. You could modify it in detectron2/engine/defaults.py.

Data pre-processing

(1) Generate the entity information of each image by the instance and panoptic annotation. Please change the path of coco annotation files in the following code.

cd /path/to/detectron2/projects/EntitySeg/make_data
bash make_entity_mask.sh

(2) Change the generated entity information to the json files.

cd /path/to/detectron2/projects/EntitySeg/make_data
python3 entity_to_json.py

Training

To train model with 8 GPUs, run:

cd /path/to/detectron2
python3 projects/EntitySeg/train_net.py --config-file <projects/EntitySeg/configs/config.yaml> --num-gpus 8

For example, to launch entity segmentation training (1x schedule) with ResNet-50 backbone on 8 GPUs and save the model in the path "/data/entity_model". one should execute:

cd /path/to/detectron2
python3 projects/EntitySeg/train_net.py --config-file projects/EntitySeg/configs/entity_default.yaml --num-gpus 8 OUTPUT_DIR /data/entity_model

Evaluation

To evaluate a pre-trained model with 8 GPUs, run:

cd /path/to/detectron2
python3 projects/EntitySeg/train_net.py --config-file <config.yaml> --num-gpus 8 --eval-only MODEL.WEIGHTS model_checkpoint

Visualization

To visualize some image result of a pre-trained model, run:

cd /path/to/detectron2
python3 projects/EntitySeg/demo_result_and_vis.py --config-file <config.yaml> --input <input_path> --output <output_path> MODEL.WEIGHTS model_checkpoint MODEL.CONDINST.MASK_BRANCH.USE_MASK_RESCORE "True"

For example,

python3 projects/EntitySeg/demo_result_and_vis.py --config-file projects/EntitySeg/configs/entity_swin_lw7_1x.yaml --input /data/input/*.jpg --output /data/output MODEL.WEIGHTS /data/pretrained_model/R_50.pth MODEL.CONDINST.MASK_BRANCH.USE_MASK_RESCORE "True"

Pretrained weights of Swin Transformers

Use the tools/convert_swin_to_d2.py to convert the pretrained weights of Swin Transformers to the detectron2 format. For example,

pip install timm
wget https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_tiny_patch4_window7_224.pth
python tools/convert_swin_to_d2.py swin_tiny_patch4_window7_224.pth swin_tiny_patch4_window7_224_trans.pth

Pretrained weights of Segformer Backbone

Use the tools/convert_mit_to_d2.py to convert the pretrained weights of SegFormer Backbone to the detectron2 format. For example,

pip install timm
python tools/convert_mit_to_d2.py mit_b0.pth mit_b0_trans.pth

Results

We provide the results of several pretrained models on COCO val set. It is easy to extend it to other backbones. We first describe the results of using CNN backbone.

Method Backbone Sched Entity AP download
Baseline R50 1x 28.3 model | metrics
Ours R50 1x 29.8 model | metrics
Ours R50 3x 31.8 model | metrics
Ours R101 1x 31.0 model | metrics
Ours R101 3x 33.2 model | metrics
Ours R101-DCNv2 3x 35.5 model | metrics

The results of using transformer backbone as follows.The Mask Rescore indicates that we use mask rescoring in inference by setting MODEL.CONDINST.MASK_BRANCH.USE_MASK_RESCORE to True.

Method Backbone Sched Entity AP Mask Rescore download
Ours Swin-T 1x 33.0 34.6 model | metrics
Ours Swin-L-W7 1x 37.8 39.3 model | metrics
Ours Swin-L-W7 3x 38.6 40.0 model | metrics
Ours Swin-L-W12 3x TBD TBD model | metrics
Ours MiT-b0 1x 28.8 30.4 model | metrics
Ours MiT-b2 1x 35.1 36.6 model | metrics
Ours MiT-b3 1x 36.9 38.5 model | metrics
Ours MiT-b5 1x 37.2 38.7 model | metrics
Ours MiT-b5 3x TBD TBD model | metrics

Citing Ours

Consider to cite Open-World Entity Segmentation if it helps your research.

@inprocedings{qi2021open,
  title={Open World Entity Segmentation},
  author={Lu Qi, Jason Kuen, Yi Wang, Jiuxiang Gu, Hengshuang Zhao, Zhe Lin, Philip Torr, Jiaya Jia},
  booktitle={arxiv},
  year={2021}
}
Comments
  • Require help with non-existent config key error

    Require help with non-existent config key error

    Hi there, thanks for your work! It looks very interesting and i would like to test it out, however I keep running into the same problem when testing the visualization script and wondering if you could help me out.

    Steps I did:

    1. Build detectron2 from source using the same commit version and pytorch version in your README
    2. clone this repo into projects/EntitySeg
    3. Download the pretrained R50.pth model
    4. Install the panopticapi library
    5. Run python3 projects/EntitySeg/demo_result_and_vis.py --config-file projects/EntitySeg/configs/entity_swin_lw7_1x.yaml --input data/input/*.jpg --output data/output MODEL.WEIGHTS data/pretrained_model/R_50.pth MODEL.CONDINST.MASK_BRANCH.USE_MASK_RESCORE "True"

    Below is my error: error

    Any help is greatly appreciated. Thank you!

    opened by zuroh 4
  • gt_bitmasks vs gt_masks

    gt_bitmasks vs gt_masks

    It seems that entity loads gt_bitmasks from .npz files built from PNG files, instead of using gt_masks from the RLEs in the instances_*.json. Is there any particular reason for doing so? If it has to be like this, it would be favorable to provide scripts to convert coco RLE jsons into PNG files which could then be used in make_entity_mask.py

    opened by ghost 3
  • evaluation results not good

    evaluation results not good

    results of pretrained model mit_b5_1x.pth on COCO val set are not good.Here is my command:

    python projects/EntitySeg/train_net.py --config-file projects/EntitySeg/configs/entity_mit_b5_1x.yaml --num-gpus 1 --eval-only MODEL.WEIGHTS data/models/mit_b5_1x.pth MODEL.CONDINST.MASK_BRANCH.USE_MASK_RESCORE "True"

    and the results:

    [08/11 16:11:11 d2.engine.defaults]: Evaluation results for coco_2017_val_entity in csv format: [08/11 16:11:11 d2.evaluation.testing]: copypaste: Task: bbox [08/11 16:11:11 d2.evaluation.testing]: copypaste: AP,AP50,AP75,APs,APm,APl [08/11 16:11:11 d2.evaluation.testing]: copypaste: 0.0010,0.0019,0.0008,0.0004,0.0014,0.0013 [08/11 16:11:11 d2.evaluation.testing]: copypaste: Task: segm [08/11 16:11:11 d2.evaluation.testing]: copypaste: AP,AP50,AP75,APs,APm,APl [08/11 16:11:11 d2.evaluation.testing]: copypaste: 0.0006,0.0015,0.0005,0.0002,0.0008,0.0009

    opened by gezhaoDL 3
  • Graphics card requirements

    Graphics card requirements

    Hello, you‘ve mentioned at the beginning of your abstract that the traditional approach have the problem of balancing computational cost and computational time. So I want to know how much graphics card memory and computing time your method needs when conducting 2K or 6K images?And what kind of graphics card we need to run this code? Thank you.

    opened by KevinBanksB 2
  • "High Quality Segmentation for Ultra High-resolution Images" code release

    Hello guys, I've read "High Quality Segmentation for Ultra High-resolution Images" recently. Great work! I am very excited about this paper. When do you plan to release code for this paper?

    Thanks in advance.

    opened by VolodymyrAhafonov 2
  • RuntimeError:Multi GPU Training

    RuntimeError:Multi GPU Training

    Thanks for your work. I met a problem when training coco panoptic model by using multi GPUs.

    My command is python3 projects/EntitySeg/train_net.py --config-file projects/EntitySeg/configs/entity_swin_t_1x.yaml --num-gpus 4 OUTPUT_DIR entity_model . Below is my error:

    RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. This error indicates that your module has parameters that were not used in producing loss. You can enable unused parameter detection by (1) passing the keyword argument `find_unused_parameters=True` to `torch.nn.parallel.DistributedDataParallel`; (2) making sure all `forward` function outputs participate in calculating loss. If you already have done the above two steps, then the distributed data parallel module wasn't able to locate the output tensors in the return value of your module's `forward` function. Please include the loss function and the structure of the return value of `forward` of your module when reporting this issue (e.g. list, dict, iterable).
    

    Any help is greatly appreciated. Thank you!

    opened by loliq 2
  • A question in `make_entity_mask.py`

    A question in `make_entity_mask.py`

    Hello, thanks for your contribution. When I used make_entity_mask.py to genere my own annotation, I found a problem in generating entity mask. When a small object is contained by a large object, if the small object is annotated first, the annotation of the small object will be covered by the annotation of the large object later. For example, in the picture below, the object in the red frame is covered image

    By the way, my task is open world instance segmentation, I think this problem will not be met in the panoptic segmentation because the different annotation format. My method is to annotate objects according to their area from large to small, so that small objects will not be covered.

    opened by loliq 0
  • "High Quality Segmentation for Ultra High-resolution Images" don't see the difference between image

    hello, thanks for your great work High Quality Segmentation. I want to ask the following 2 questions

    1. I don't see any difference in P position information between images. Even in an image, the information of the variable rel_cell is the same in all locations. So why can CRM generate detailed segmentation masks?
    2. What is the meaning of calculating 3 features in P because it seems to me that it is hard-fixed and concatenated into each feature of the image? below is the map that I printed out for the variables

    image image

    opened by trinh-hoang-hiep 1
  • How to Set the

    How to Set the "find_unused_parameters=True" After Installing Detectron2

    When I train with 2 GPUs, I have the same problem in https://github.com/facebookresearch/detectron2/issues/4191. Thus, after reading your README.MD, I want to know how to set the "find_unused_parameters=True" in distributed training of my own detectron2. I have tried to set the "find_unused_parameters=True" in the detectron2/engine/defaults.py image Thus, I want to ask you whether I change it correctly. I am looking forward to your response.

    opened by 15024287710Jackson 2
  • AssertionError: Adding a field of length 0 to a Instances of length 2

    AssertionError: Adding a field of length 0 to a Instances of length 2

    Hi, I am getting the following error when running this coarse partition network with train2017 dataset

    ERROR [08/05 15:18:06 d2.engine.train_loop]: Exception during training: Traceback (most recent call last): File "/home/hndx/detectron2-main/detectron2/engine/train_loop.py", line 149, in train self.run_step() File "/home/hndx/detectron2-main/detectron2/engine/defaults.py", line 494, in run_step self._trainer.run_step() File "/home/hndx/detectron2-main/detectron2/engine/train_loop.py", line 268, in run_step data = next(self._data_loader_iter) File "/home/hndx/detectron2-main/detectron2/data/common.py", line 234, in iter for d in self.dataset: File "/home/hndx/anaconda3/envs/llz0/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 521, in next data = self._next_data() File "/home/hndx/anaconda3/envs/llz0/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1203, in _next_data return self._process_data(data) File "/home/hndx/anaconda3/envs/llz0/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1229, in _process_data data.reraise() File "/home/hndx/anaconda3/envs/llz0/lib/python3.7/site-packages/torch/_utils.py", line 434, in reraise raise exception AssertionError: Caught AssertionError in DataLoader worker process 0. Original Traceback (most recent call last): File "/home/hndx/anaconda3/envs/llz0/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop data = fetcher.fetch(index) File "/home/hndx/anaconda3/envs/llz0/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 32, in fetch data.append(next(self.dataset_iter)) File "/home/hndx/detectron2-main/detectron2/data/common.py", line 201, in iter yield self.dataset[idx] File "/home/hndx/detectron2-main/detectron2/data/common.py", line 90, in getitem data = self._map_func(self._dataset[cur_idx]) File "/home/hndx/detectron2-main/detectron2/utils/serialize.py", line 26, in call return self._obj(*args, **kwargs) File "/home/hndx/detectron2-main/detectron2/projects/EntitySeg/entityseg/data/dataset_mapper.py", line 197, in call instances.instanceid = instance_id_list File "/home/hndx/detectron2-main/detectron2/structures/instances.py", line 66, in setattr self.set(name, val) File "/home/hndx/detectron2-main/detectron2/structures/instances.py", line 84, in set ), "Adding a field of length {} to a Instances of length {}".format(data_len, len(self)) ##lizhi long

    opened by longlizhi 2
  • can't test

    can't test "High Quality Segmentation for Ultra High-resolution Images"

    I run test.py but i met this error, miss "_seg.png" file

    python test.py --dir ./data/DUTS-TE --model ./model_10000 --output ./output --clear /home/hoang/anaconda3/envs/tranSOD/lib/python3.6/site-packages/torchvision/io/image.py:11: UserWarning: Failed to load image Python extension: /home/hoang/anaconda3/envs/tranSOD/lib/python3.6/site-packages/torchvision/image.so: undefined symbol: _ZNK2at10TensorBase21__dispatch_contiguousEN3c1012MemoryFormatE warn(f"Failed to load image Python extension: {e}")

    before_Parser_time: 1659253874.6776164 Hyperparameters: {'dir': './data/DUTS-TE', 'model': './model_10000', 'output': './output', 'global_only': False, 'L': 900, 'stride': 450, 'clear': True, 'ade': False} ASPP_4level 12 images found

    before_for_time: 1659253881.0989463 ; before_for_time - before_Parser_time: 6.421329975128174 Traceback (most recent call last): File "test.py", line 106, in for im, seg, gt, name, crm_data in progressbar.progressbar(val_loader): File "/home/hoang/anaconda3/envs/tranSOD/lib/python3.6/site-packages/progressbar/shortcuts.py", line 10, in progressbar for result in progressbar(iterator): File "/home/hoang/anaconda3/envs/tranSOD/lib/python3.6/site-packages/progressbar/bar.py", line 547, in next value = next(self._iterable) File "/home/hoang/anaconda3/envs/tranSOD/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 521, in next data = self._next_data() File "/home/hoang/anaconda3/envs/tranSOD/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 561, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/home/hoang/anaconda3/envs/tranSOD/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/hoang/anaconda3/envs/tranSOD/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/hoang/Desktop/luanvan/implicitmodel/4cham/Entity/High-Quality-Segmention/dataset/offline_dataset_crm_pad32.py", line 138, in getitem im, seg, gt = self.load_tuple(self.im_list[idx]) File "/home/hoang/Desktop/luanvan/implicitmodel/4cham/Entity/High-Quality-Segmention/dataset/offline_dataset_crm_pad32.py", line 110, in load_tuple seg = Image.open(im[:-7]+'_seg.png').convert('L') File "/home/hoang/anaconda3/envs/tranSOD/lib/python3.6/site-packages/PIL/Image.py", line 2975, in open fp = builtins.open(filename, "rb") FileNotFoundError: [Errno 2] No such file or directory: './data/DUTS-TE/sun_abzsyxfgntlvd_seg.png'

    opened by trinh-hoang-hiep 16
  • AssertionError: No valid data found in coco_2017_train_entity.

    AssertionError: No valid data found in coco_2017_train_entity.

    Hi, why do I get this error when I run the coco instance_2017 dataset with the source program? This error is as follows

    Traceback (most recent call last): File "/home/hndx/detectron2-main/detectron2/projects/EntitySeg/train_net.py", line 81, in args=(args,), File "/home/hndx/detectron2-main/detectron2/engine/launch.py", line 82, in launch main_func(*args) File "/home/hndx/detectron2-main/detectron2/projects/EntitySeg/train_net.py", line 67, in main trainer = Trainer(cfg) File "/home/hndx/detectron2-main/detectron2/engine/defaults.py", line 378, in init data_loader = self.build_train_loader(cfg) File "/home/hndx/detectron2-main/detectron2/projects/EntitySeg/train_net.py", line 33, in build_train_loader return build_detection_train_loader(cfg, mapper) File "/home/hndx/detectron2-main/detectron2/config/config.py", line 207, in wrapped explicit_args = _get_args_from_config(from_config, *args, **kwargs) File "/home/hndx/detectron2-main/detectron2/config/config.py", line 245, in _get_args_from_config ret = from_config_func(*args, **kwargs) File "/home/hndx/detectron2-main/detectron2/data/build.py", line 350, in _train_loader_from_config proposal_files=cfg.DATASETS.PROPOSAL_FILES_TRAIN if cfg.MODEL.LOAD_PROPOSALS else None, File "/home/hndx/detectron2-main/detectron2/data/build.py", line 278, in get_detection_dataset_dicts assert len(dataset_dicts), "No valid data found in {}.".format(",".join(names)) AssertionError: No valid data found in coco_2017_train_entity.

    opened by longlizhi 2
  • The wrong segmentation result in ''High Quality Segmentation...

    The wrong segmentation result in ''High Quality Segmentation..."

    Hi, I have tried to realize your method(High Quality Segmentation for Ultra High-resolution Images), it works well. But do you have met the problem that the wrong mask segmentation happens when the RGB-image area is similar to the real label area color. For example , I want to segment the sky area, but the white wall also to be thinked as sky.

    opened by Ianresearch 3
Owner
DV Lab
Deep Vision Lab
DV Lab
Video-based open-world segmentation

UVO_Challenge Team Alpes_runner Solutions This is an official repo for our UVO Challenge solutions for Image/Video-based open-world segmentation. Our

Yuming Du 84 Dec 22, 2022
A heterogeneous entity-augmented academic language model based on Open Academic Graph (OAG)

Library | Paper | Slack We released two versions of OAG-BERT in CogDL package. OAG-BERT is a heterogeneous entity-augmented academic language model wh

THUDM 58 Dec 17, 2022
TorchDistiller - a collection of the open source pytorch code for knowledge distillation, especially for the perception tasks, including semantic segmentation, depth estimation, object detection and instance segmentation.

This project is a collection of the open source pytorch code for knowledge distillation, especially for the perception tasks, including semantic segmentation, depth estimation, object detection and instance segmentation.

yifan liu 147 Dec 3, 2022
PyTorch CZSL framework containing GQA, the open-world setting, and the CGE and CompCos methods.

Compositional Zero-Shot Learning This is the official PyTorch code of the CVPR 2021 works Learning Graph Embeddings for Compositional Zero-shot Learni

EML Tübingen 70 Dec 27, 2022
Learning Open-World Object Proposals without Learning to Classify

Learning Open-World Object Proposals without Learning to Classify Pytorch implementation for "Learning Open-World Object Proposals without Learning to

Dahun Kim 149 Dec 22, 2022
the code for paper "Energy-Based Open-World Uncertainty Modeling for Confidence Calibration"

EOW-Softmax This code is for the paper "Energy-Based Open-World Uncertainty Modeling for Confidence Calibration". Accepted by ICCV21. Usage Commnd exa

Yezhen Wang 36 Dec 2, 2022
Pytorch implementation for "Large-Scale Long-Tailed Recognition in an Open World" (CVPR 2019 ORAL)

Large-Scale Long-Tailed Recognition in an Open World [Project] [Paper] [Blog] Overview Open Long-Tailed Recognition (OLTR) is the author's re-implemen

Zhongqi Miao 761 Dec 26, 2022
[NeurIPS 2021] “Improving Contrastive Learning on Imbalanced Data via Open-World Sampling”,

Improving Contrastive Learning on Imbalanced Data via Open-World Sampling Introduction Contrastive learning approaches have achieved great success in

VITA 24 Dec 17, 2022
Towards Open-World Feature Extrapolation: An Inductive Graph Learning Approach

This repository holds the implementation for paper Towards Open-World Feature Extrapolation: An Inductive Graph Learning Approach Download our preproc

Qitian Wu 42 Dec 27, 2022
RE-OWOD - Revisiting open world object detection

Revisting Open World Object Detection Installation See INSTALL.md. Dataset Our n

null 7 Jan 5, 2022
[CVPR 2022] Official Pytorch code for OW-DETR: Open-world Detection Transformer

OW-DETR: Open-world Detection Transformer (CVPR 2022) [Paper] Akshita Gupta*, Sanath Narayan*, K J Joseph, Salman Khan, Fahad Shahbaz Khan, Mubarak Sh

Akshita Gupta 127 Dec 27, 2022
A platform for intelligent agent learning based on a 3D open-world FPS game developed by Inspir.AI.

Wilderness Scavenger: 3D Open-World FPS Game AI Challenge This is a platform for intelligent agent learning based on a 3D open-world FPS game develope

null 46 Nov 24, 2022
A multi-entity Transformer for multi-agent spatiotemporal modeling.

baller2vec This is the repository for the paper: Michael A. Alcorn and Anh Nguyen. baller2vec: A Multi-Entity Transformer For Multi-Agent Spatiotempor

Michael A. Alcorn 56 Nov 15, 2022
git《Joint Entity and Relation Extraction with Set Prediction Networks》(2020) GitHub:

Joint Entity and Relation Extraction with Set Prediction Networks Source code for Joint Entity and Relation Extraction with Set Prediction Networks. W

null 130 Dec 13, 2022
Code for paper "A Critical Assessment of State-of-the-Art in Entity Alignment" (https://arxiv.org/abs/2010.16314)

A Critical Assessment of State-of-the-Art in Entity Alignment This repository contains the source code for the paper A Critical Assessment of State-of

Max Berrendorf 16 Oct 14, 2022
Weakly supervised medical named entity classification

Trove Trove is a research framework for building weakly supervised (bio)medical named entity recognition (NER) and other entity attribute classifiers

null 60 Nov 18, 2022
An Easy-to-use, Modular and Prolongable package of deep-learning based Named Entity Recognition Models.

DeepNER An Easy-to-use, Modular and Prolongable package of deep-learning based Named Entity Recognition Models. This repository contains complex Deep

Derrick 9 May 30, 2022
Chinese clinical named entity recognition using pre-trained BERT model

Chinese clinical named entity recognition (CNER) using pre-trained BERT model Introduction Code for paper Chinese clinical named entity recognition wi

Xiangyang Li 109 Dec 14, 2022
Source code and dataset for ACL2021 paper: "ERICA: Improving Entity and Relation Understanding for Pre-trained Language Models via Contrastive Learning".

ERICA Source code and dataset for ACL2021 paper: "ERICA: Improving Entity and Relation Understanding for Pre-trained Language Models via Contrastive L

THUNLP 75 Nov 2, 2022