Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

BDD100K #264

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open

BDD100K #264

wants to merge 44 commits into from

Conversation

Linstancy
Copy link

Hi, I want to train BDD100K on the detectron framework. Did you have completed it, or could you please give me some guidance about BDD100K trained on faster rcnn or mask rcnn?

Thanks a lot.

Looking forard for your reply!

martinruenz and others added 30 commits October 24, 2018 17:37
Fix a small typo
It is simpler and requires less effort (i.e. no auth) compared to SSH
* Add missing __init__.py files

* Add packages

* Rename logging.py to logger.py

Import rules from Python2 makes this a bad idea

* Make import_file py2 compatible

* list does not have .copy() in py2

* math.log2 does not exist in py2

* Miscellaneous fixes for py2

* Address comments
Fix BoxList constructor call in README.md
Replace baseline with benchmark
Replace BoxList argument size with image_size.
use cuda version torch.randperm to avoid copy from gpu to cpu and a fatal bug in multi-thread cpu version
* quick fix for area

* Update bounding_box.py
)

## Bug
When I repeatedly invoke build_detection_model function to build the model, I will get the error: `AttributeError: 'ResNet' object has no attribute 'layer1'`. 

## To Reproduce
```
model = build_detection_model(cfg)
model = build_detection_model(cfg)
```

## The reason
The variable `ResNet50StagesTo4` is a global generator expression, so when we build the model secondly, the code executes to Line 82 `for stage_spec in stage_specs:` and `stage_specs` will return empty leading to do not add any stage. Finally, `self._freeze_backbone` try to freeze the backbone by executing `m = getattr(self, "layer" + str(stage_index))` firstly. At the moment, it will throw the AttributeError `AttributeError: 'ResNet' object has no attribute 'layer1'`.

I guess you want to define ResNet50StagesTo4 as the tuple, so I try to fix by add tuple type qualifier.

## The solution
Add the tuple type to `ResNet50StagesTo5`, `ResNet50StagesTo4`, `ResNet50FPNStagesTo5`, `ResNet101FPNStagesTo5`.

I do not know whether there are similar bug existing, so you need to review my solution. Thank you!
* Inference/evaluation in BDD format

* Tensorboard support
@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@fmassa
Copy link
Contributor

fmassa commented Dec 11, 2018

Hi,

So, just to clarify: is your code working and giving expected results or not?
I haven't myself trained any models on BDD100k dataset, so I might not be able to help on particular aspects of it.

Also, the branch has several conflicts with the current master which would be good to be addressed if you would like to see this PR merged.

Thanks!

@Linstancy
Copy link
Author

Linstancy commented Dec 12, 2018 via email

@fmassa
Copy link
Contributor

fmassa commented Dec 12, 2018

Hi,

Did you check the content of this file? I think it will be very helpful as a starting point.

@fmassa
Copy link
Contributor

fmassa commented Dec 12, 2018

Also, it would be very helpful to know what are the specific questions your have. Creating a new dataset should be quite straightforward, the most involved part is getting it to work correctly with the evaluation code

@Linstancy
Copy link
Author

Linstancy commented Dec 12, 2018 via email

@fmassa
Copy link
Contributor

fmassa commented Dec 13, 2018

You can convert the BDD ground-truth data to COCO format, and things should run smoothly.
But this is not strictly necessary, because you can write your own Dataset class for it and the rest should work without problems, apart from the evaluation part, which requires a bit more work.

@Linstancy
Copy link
Author

Linstancy commented Dec 13, 2018 via email

@Linstancy
Copy link
Author

Hi, when I ran the command 'python tools/train_net.py --config-file configs/e2e_faster_rcnn_R_50_C4_1x.yaml' to train my BDD100K dataset, I met with this bug. How can I solve it? The dataset class was compiled, and according dataset file has already been prepared. But I still encountered the bug as follows, could you help me or give me some guidance?

ImportError: cannot import name '_C' from 'maskrcnn_benchmark' (/mnt/nfsdir/lambda-cloud/data/lcm/github/Detector-KITTI-BDD100k/maskrcnn_benchmark/init.py)

Thanks a lot! And I am looking forward for your letters!

@fmassa
Copy link
Contributor

fmassa commented Dec 14, 2018

@Linstancy it looks like you haven't installed maskrcnn-benchmark following the installation instructions.

About how to write a Dataset class, you just need to implement a __getitem__ method that returns the image, the BoxList object and the image idx.
Creating the BoxList is the only new thing compared to other PyTorch projects, and it should be very straightforward.

I'd recommend trying to check in a jupyter notebook or in the interpreter if the current implementation that you have is giving expected results. Also, I'm not sure what the format for the segmentation masks in BDD100k, is it a list of polygons or binary masks?

@Linstancy
Copy link
Author

Linstancy commented Dec 14, 2018 via email

@fmassa
Copy link
Contributor

fmassa commented Dec 14, 2018

@Linstancy can you run the demos using one of the pre-trained models? I think there is a problem with your installation.

Upon a quick look at your code for the dataset it looks reasonable. I'm not sure where / what are the errors you are getting, but I believe you might be almost there to fix it and get it running.

@Linstancy
Copy link
Author

Linstancy commented Dec 14, 2018 via email

@fmassa
Copy link
Contributor

fmassa commented Dec 14, 2018

I think you might be better off trying first to run some working examples, like the demo.
You might probably need to reinstall it, as the current installation doesn't seem to be working.

@Linstancy
Copy link
Author

Linstancy commented Dec 14, 2018 via email

@Linstancy
Copy link
Author

Linstancy commented Dec 14, 2018 via email

@fmassa
Copy link
Contributor

fmassa commented Dec 17, 2018

Could you please try uninstalling maskrcnn-benchmark (by removing the build folder), and try installing it again? You might have conflicts with the gcc version, which might be < 4.9

* fix kitti training script

* fix
* fix bdd

* Update README.md
@csoehnel
Copy link

csoehnel commented Mar 7, 2019

@Linstancy maybe you'll find the converter I wrote useful as a starting point. It's in my fork:
https://github.com/csoehnel/maskrcnn-benchmark/blob/master/tools/bdd100k/convert_bdd100k2coco.py

* bdd100k evaluation

* minor fix
* train bdd detection in coco format

* Update coco.py

* Gradient clipping
@MoonBlvd
Copy link

Has anyone successfully trained Mask-RCNN on BDD100K?
I used the COCO pre-trained weight and pruned the model so that the top layer outputs 11 classes (the same to BDD). Since BDD100K doesn't have instance segmentation, I set MASK_ON=False. I trained for 200,000 iterations, the validation loss decreased very slowly. I tested the final checkpoint as well as some intermediate checkpoints and the AP was almost the same to the test result of the COCO pre-trained model.
I wonder if any one have trained on BDD100K and seen significant improvement of the AP...

P.s. I trained on Cityscapes using the COCO pre-trained weight as well and during the 100,000 iterations, the validation loss decreases quickly and the AP had a large improvement...

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

Successfully merging this pull request may close these issues.