# MASK-RCNN (matterort)
## Clone and Install repository
- clone the Mask-RCNN project (Tensorflow 2.0)
- GITHUB: https://github.com/akTwelve/Mask_RCNN (v2.0)
- Install dependencies
- open anaconda
- ```conda create --name=maskrcnn python=3.8```
- ```conda activate maskrcnn```
- Enter the maskrcnn folder
- ```pip install -r requirements.txt```
- ```pip install pydicom```
- ```python setup.py install```
- ※ 2021/03/08
- Tensorflow-GPU = 2.4.0
- the CUDA_LOAD_FAILED ERROR was solved after installed numpy==1.19.3
## Training
- Code
- dataset_arrangement.py **-- build dataset from dcm and json file of samples.**
- train.py **-- for training maskrcnn model with custom dataset**
- Prepare your dataset
- edit dataset_arrangement.py
```
sourceDataset = 'E:/creomed_dataHospital_cjmain/ed-mr-brain-meta'
targetDataset = 'E:/creomed_model_trained_cjmain/meta/dataset'
datasetRate = [0.8, 0.1, 0.1]
```
- The source dataset should contain all images and label data.
- The target dataset will create the train, validation, and test folders with the specified dataset rate (datasetRate).
- excute ``` python dataset_arrangment ```
- Training
- cd to mask-rcnn folder (e.x. E:/Mask_RCNN-master)
- excute ``` train.py train --weight=coco --dataset=/path/to/targetDataset ```
- Change hyperparameter
- go to the Mask_RCNN folder/mrcnn
- open the **config.py**, you can change the resolution or BACKBONE, etc.
- Save the revised file.
- go back to the Mask_RCNN folder and execute ```python setup.py install``` to reload the config setting.
## Inference
## Others
- multi-class training (with labelme)
- https://blog.csdn.net/qq_26850561/article/details/100728042
- https://blog.csdn.net/qq_28663849/article/details/112309779?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-2&spm=1001.2101.3001.4242
- [labelme2coco](https://github.com/matterport/Mask_RCNN/issues/1704)
> So, you have 5 "small" losses:
>
> rpn_class_loss : How well the Region Proposal Network separates background with objetcs
> rpn_bbox_loss : How well the RPN localize objects
> mrcnn_bbox_loss : How well the Mask RCNN localize objects
> mrcnn_class_loss : How well the Mask RCNN recognize each class of object
> mrcnn_mask_loss : How well the Mask RCNN segment objects
> That makes a bigger loss:
>
> loss : A combination (surely an addition) of all the smaller losses.
> All of those losses are calculated on the training dataset.
>
> The losses for the validation dataset are those starting with 'val'
>
> Hope this helps.