Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cityscapes dataset #1037

Merged
merged 15 commits into from
Jul 27, 2019
Merged

Add cityscapes dataset #1037

merged 15 commits into from
Jul 27, 2019

Conversation

michaelisc
Copy link
Contributor

Dataset class and config files for cityscapes.

Annotation format:
The annotations have to be converted into the coco format following the example of maskrcnn-benchmark. The results are evaluated using the pycocotools.

Current status: working
The configs and dataset class are final and working. The results in config/cityscapes/README.md are reproducible and I am happy to provide the checkpoints.

Open points:

  • I still have to take the time to go over the annotation conversion code again and clean it up. If I remember correctly there were some bugs in the maskrcnn-benchmark version, that I wanted to fix.
  • The provided configs use multi-scale training to reproduce the results from the Mask R-CNN paper. This might however be suboptimal, as it differs from how the coco models are configured.
  • I have no way of hosting the checkpoints and my setup differs slightly from that of the modelzoo models.

@hellock
Copy link
Member

hellock commented Jul 23, 2019

Nice work! Thanks for providing the results on cityscapes. It is okay to adopt multi-scale training since it is almost a convention for this dataset. We can retrain the model with 8 GPUs and compare with your single-gpu results (@yhcao6 please help to verify that). If you figure out the bug in the conversion script, welcome to fix & provide a copy in tools/convert_datasets/.

BTW, there are some linting errors, could you fix them?

@michaelisc
Copy link
Contributor Author

When retraining the model on 8 gpus you can use the learning rate from the config file, it is set for 8 gpus. I downscaled it by a factor of 8 (see the linear scaling rule pull request) for training on 1 gpu.

The linting errors should be fixed.

@yhcao6
Copy link
Collaborator

yhcao6 commented Jul 24, 2019

When I run the code, I met some problems, please have a look to see if there are something wrong.

  1. The first error show KeyError: 'None is not in the dataset registry'. So that I add @DATASETS.register_module before class CityscapesDataset(CocoDataset): in cityscapes.py , this resolve the problem.

  2. When I setup the dataset as install.md and ran the program, it report the error
    FileNotFoundError: img file does not exist: data/cityscapes/train/cologne_000102_000019_leftImg8bit.png
    Then I found the actual image path is data/cityscapes/train/cologne/cologne_000102_000019_leftImg8bit.png. I wonder if I did something wrong.

@michaelisc
Copy link
Contributor Author

@yhcao6 I think the first issue came up, because you changed the dataset handling in the meantime and I did not check the code again after merging. I added '@DATASETS.register_module' to the 'CityscapesDatasets' definition in the commit above.

I think the second error is exactly what I hit too. Either the additional folders have to be added to the filepaths in the annotation or the files have to be extracted from the folders. I decided to do the ladder using 'cp' and some '*'s. However I forgot the exact command and have to try it out again.

@michaelisc
Copy link
Contributor Author

michaelisc commented Jul 24, 2019

@yhcao6 the right command is: 'mv train/*/* train/'. I will try to look at the conversion scripts soon but am pretty busy the next two weeks. If it works with their scripts and the only thing you have to do is this file moving I can quickly write either a '.sh' function or add this into the conversion code.

@yhcao6
Copy link
Collaborator

yhcao6 commented Jul 24, 2019

Report 8 gpu results here. I didn't change anything, but fix the dataset registry and move image.
Faster R50: 36.6
Mask R50: 38.3/33.1

@hellock
Copy link
Member

hellock commented Jul 25, 2019

Report 8 gpu results here. I didn't change anything, but fix the dataset registry and move image.
Faster R50: 36.6
Mask R50: 38.3/33.1

We can run it for 3 times and take the mid value. Then the model zoo can be updated.

@yhcao6
Copy link
Collaborator

yhcao6 commented Jul 25, 2019

I ran the code three times, the fluctuation seems really large,
faster r50: 36.6, 35.8, 36.0
mask r50: 38.3/33.1, 37.2/32.0, 37.4/32.5
Is this normal?

@michaelisc
Copy link
Contributor Author

michaelisc commented Jul 25, 2019

I guess this is a result of the extremely small data set size (only 5000 images). Any suggestions how to handle this? Finetuning from a Coco checkpoint might reduce the fluctuations (and should result in better performance) but I did not have time yet to implement this.

@yhcao6
Copy link
Collaborator

yhcao6 commented Jul 27, 2019

I add benchmark for these two models. Please have a look to see if there is any problem.


## Environment

### Hardware
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be removed since we tested different hardwares and the performances are comparable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed


## Common settings

- All baselines were trained using 1 GPU with a batch size of 2 (2 images per GPU) using the [linear scaling rule](https://arxiv.org/abs/1706.02677) to scale the learning rate. The learning rate in the configs is set for a batch size of 16 to match the default of the coco models.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 GPUs now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just add in your setup descriptions?


| Backbone | Style | Lr schd | Scale | Pretraining | Mem (GB) | Train time (s/iter) | Inf time (fps) | box AP | mask AP | Download |
| :-------------: | :-----: | :-----: | :---: | :---------: | :----: | :----: | :----: | :----: | :-----: | :------: |
| R-50-FPN | pytorch | 1x | 800-1024 | Backbone | 4.9 | 0.609 | 2.5 | 37.4 | 32.5 | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/cityscapes/mask_rcnn_r50_fpn_1x_city_20190727-9b3c56a5.pth) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inference time seems abnormal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just caused by the image resolution.


| Backbone | Style | Lr schd | Scale | Pretraining | Mem (GB) | Train time (s/iter) | Inf time (fps) | box AP | Download |
| :-------------: | :-----: | :-----: | :---: | :---------: | :----: | :----: | :----: | :----: | :------: |
| R-50-FPN | pytorch | 1x | 800-1024 | Backbone | 4.9 | 0.345 | 8.8 | 36.0 | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/cityscapes/faster_rcnn_r50_fpn_1x_city_20190727-7b9c0534.pth) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use Y/N for pretraining.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to specify wether we used coco pretraining. Probably we should just remove this field until we have coco pretrained models and mention somewhere else, that we trained from scratch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can just remove this column. In this repo, pretraining usually means using the pretrained model from ImageNet and scratch means no pretrained weights for backbones. If we further add models pretrained from COCO and finetuned on CityScapes, we need to clearly indicate that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Let's think about that once we have the finetuned models.

@hellock
Copy link
Member

hellock commented Jul 27, 2019

@michaelisc Let me know if you have any other comments? This PR looks good to me.

@michaelisc
Copy link
Contributor Author

@yhcao6 did you end up moving all images into one folder or change the annotations to go thorough the foilders? I think we should mention this processing step somewhere.

Apart from that it looks good to me!

INSTALL.md Outdated
│ ├── VOCdevkit
│ │ ├── VOC2007
│ │ ├── VOC2012

```
The cityscapes annotations have to be converted into the coco format using the [cityscapesScripts](https://github.com/mcordts/cityscapesScripts) toolbox.
We plan to provide an easy to use conversion script. For the moment we recommend following the instructions provided in the
[maskrcnn-benchmark](https://github.com/facebookresearch/maskrcnn-benchmark/tree/master/maskrcnn_benchmark/data) toolbox.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yhcao6 I think this is where the description about the file handling would have to go.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just move all images into one folder. You can add it into readme.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Contributor Author

@michaelisc michaelisc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me

Update information how to arrange cityscapes data.
Copy link
Contributor Author

@michaelisc michaelisc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything should be fine now.

@michaelisc
Copy link
Contributor Author

Ah, I found something I missed. I don't think I have added cityscapes to mmde.core.get_classes. Shouldn't be a big deal though.

@hellock
Copy link
Member

hellock commented Jul 27, 2019

Ah, I found something I missed. I don't think I have added cityscapes to mmde.core.get_classes. Shouldn't be a big deal though.

It will not affect the training and testing, since the class labels are now obtained from the dataset itself. It may be useful for users who want to do something else though.

@michaelisc
Copy link
Contributor Author

Ah, I found something I missed. I don't think I have added cityscapes to mmde.core.get_classes. Shouldn't be a big deal though.

It will not affect the training and testing, since the class labels are now obtained from the dataset itself. It may be useful for users who want to do something else though.

That's why I did not bump into this earlier. I only ran into it when trying to visualize the results of a different dataset.

@hellock
Copy link
Member

hellock commented Jul 27, 2019

Yep, so you can add it for potential usage, and I will merge this PR.

@michaelisc
Copy link
Contributor Author

Added the class names. From my side this is ready to be merged.

@hellock hellock merged commit 1c28e66 into open-mmlab:master Jul 27, 2019
pjpjq pushed a commit to pjpjq/mmdetection that referenced this pull request Jul 28, 2019
* added cityscapes

* updated configs

* removed wip configs

* Add initial dataset instructions

* Add cityscapes readme

* Add explanation for lr scaling

* Ensure pep8 conformity

* Add CityscapesDataset to the registry

* add benchmark

* rename config, modify README.md

* fix typo

* fix typo in config

* modify INSTALL.md

Update information how to arrange cityscapes data.

* Add cityscapes class names
@nemonameless
Copy link

nemonameless commented Sep 18, 2019

However, I think your mAP in coco protocol is not in conformity with the protocol of cityscapes evaluation https://github.com/mcordts/cityscapesScripts .Although your mAP is higher than the original MASK RCNN paper, it may be pseudomorph. I have trained cityscapes(only fine) using your code and even get 43.0 mask mAP in val-set in coco protocol, but it is only 30.6 when evaluate the val-set with cityscapesScripts,and only 27.3 on the leaderboard(test-set) of cityscapes.

And could you provide your instancesonly_filtered_gtFine_val.json and instancesonly_filtered_gtFine_train.json? Thanks.

I follow the maskrcnn-benchmark and get jsons, but when testing your trained model(https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/cityscapes/mask_rcnn_r50_fpn_1x_city_20190727-9b3c56a5.pth), I onlt get only 23.9 bbox mAP and 19.9 mask mAP in coco protocol.
Thanks. @michaelisc @yhcao6 @hellock

@dhananjaisharma10
Copy link
Contributor

dhananjaisharma10 commented Nov 10, 2019

When I run the code, I met some problems, please have a look to see if there are something wrong.

  1. The first error show KeyError: 'None is not in the dataset registry'. So that I add @DATASETS.register_module before class CityscapesDataset(CocoDataset): in cityscapes.py , this resolve the problem.
  2. When I setup the dataset as install.md and ran the program, it report the error
    FileNotFoundError: img file does not exist: data/cityscapes/train/cologne_000102_000019_leftImg8bit.png
    Then I found the actual image path is data/cityscapes/train/cologne/cologne_000102_000019_leftImg8bit.png. I wonder if I did something wrong.

Hi! I am trying to train on the Cityscapes dataset as well. I seem to be running into a similar error:

FileNotFoundError: img file does not exist: /home/Cityscapes/gtFine_trainvaltest/gtFine/train/bochum_000000_037223_leftImg8bit.png

When I checked I found that I did not have a single image with a suffix leftImg8bit.png. I am using gtFine_trainvaltest.zip (241MB) for training. Are you using the same dataset or something else?

The error seems to be originating because the convert_cityscapes_to_coco.py script from maskrcnn-benchmark does something like:

image['file_name'] = filename[:-len(
                        ends_in % data_set.split('_')[0])] + 'leftImg8bit.png'

but never writes an image under that name. Please let me know where I'm going wrong. Thanks!

@dhananjaisharma10
Copy link
Contributor

When I run the code, I met some problems, please have a look to see if there are something wrong.

  1. The first error show KeyError: 'None is not in the dataset registry'. So that I add @DATASETS.register_module before class CityscapesDataset(CocoDataset): in cityscapes.py , this resolve the problem.
  2. When I setup the dataset as install.md and ran the program, it report the error
    FileNotFoundError: img file does not exist: data/cityscapes/train/cologne_000102_000019_leftImg8bit.png
    Then I found the actual image path is data/cityscapes/train/cologne/cologne_000102_000019_leftImg8bit.png. I wonder if I did something wrong.

Hi! I am trying to train on the Cityscapes dataset as well. I seem to be running into a similar error:

FileNotFoundError: img file does not exist: /home/Cityscapes/gtFine_trainvaltest/gtFine/train/bochum_000000_037223_leftImg8bit.png

When I checked I found that I did not have a single image with a suffix leftImg8bit.png. I am using gtFine_trainvaltest.zip (241MB) for training. Are you using the same dataset or something else?

The error seems to be originating because the convert_cityscapes_to_coco.py script from maskrcnn-benchmark does something like:

image['file_name'] = filename[:-len(
                        ends_in % data_set.split('_')[0])] + 'leftImg8bit.png'

but never writes an image under that name. Please let me know where I'm going wrong. Thanks!

Never mind. I downloaded the leftImg8bit_trainvaltest.zip (11GB) dataset which has the original images. Thank you!

JegernOUTT pushed a commit to JegernOUTT/mmdetection that referenced this pull request Nov 23, 2019
* added cityscapes

* updated configs

* removed wip configs

* Add initial dataset instructions

* Add cityscapes readme

* Add explanation for lr scaling

* Ensure pep8 conformity

* Add CityscapesDataset to the registry

* add benchmark

* rename config, modify README.md

* fix typo

* fix typo in config

* modify INSTALL.md

Update information how to arrange cityscapes data.

* Add cityscapes class names
FANGAreNotGnu pushed a commit to FANGAreNotGnu/mmdetection that referenced this pull request Oct 23, 2023
…AT, XGB (open-mmlab#1037)

* Tabular: Added support for specifying early stopping rounds in GBM, CAT, XGB

* addressed comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants