Mstfakts / Building-Detection-MaskRCNN

Building detection from the SpaceNet dataset by using Mask RCNN.
224 stars 22 forks source link

Cannot use pre-trained file cannot be used in matterport/Mask-RCNN #4

Open hideoshiraishi opened 3 years ago

hideoshiraishi commented 3 years ago

It would be appreciated if someone clarify how to implement building detection using pre-trained file and matterport's Mask-RCNN.

Before getting into the building detection, I could run "demo.ipynb" in "sample" folder in matterport's repository and detect objects using some my own images.

Now, I am trying to change the original pre-trained file (mask_rcnn_coco.h5) to yours (mask_rcnn_spacenet_0151.h5) to detect buildings from satellite images.

Here I attached the demo_building.ipynb which I slightly modified to load your pre-trained model. The changes are really limited:

demo_building.txt As .ipynb file was not accepted, please change the extension from .txt to .ipynb.

Changing pre-trained file 1

As I am not sure of the class_names in the replaced pre-trained file, currently I just commented out class_names. Perhaps it may require some updates but I have no idea on this. 2

However, as a result, an error occurs when I run the following script as attached in the file error.txt. 3

error.txt

It would be highly appreciated if you could suggest any corrections to run the model and detect the footprints appropriately. As I am quite new in this field, please forgive me if I miss some basics.

Thank you in advance for your support.

hideoshiraishi commented 3 years ago

I have not solved the issue completely but I could run the model by changing the class name setting as below:

class_names = ['BG', 'building']

The building detection seems to be implemented somehow with baseline pre-trained file. I will look into it more detail to apply the file from your repository. Thank you!

Mstfakts commented 3 years ago

Hello Hideo,

The error is about the shape mismatch for the last layer. It's bc there are only 2 classes in the project, these are the background and the building. If you want to change the output layers, try freezing the layers except the last one.