|
1 | | -# FasterRCNN_SpringEdition |
2 | | -Easy FasterRCNN C++ library. |
| 1 | +# FasterRCNN_SpringEdition <img src="https://i.imgur.com/oYejfWp.png" title="Windows8" width="48"> |
| 2 | + |
| 3 | +###### FasterRCNN C++ library. (Train,Detect both) |
| 4 | +* All dependencies are included. |
| 5 | +* Can Train FasterRCNN as double click. |
| 6 | +* Need only 1 header file, To detect by FasterRCNN. |
| 7 | + |
| 8 | +<img src="https://i.imgur.com/ElCyyzT.png" title="Windows8" width="48"><img src="https://i.imgur.com/O5bye0l.png" width="48"> |
3 | 9 |
|
4 | 10 | ## Setup for train |
| 11 | +#### 1. Download model and files. |
| 12 | +There is a **download_model.bat** in [CNTK/FasterRCNN/](https://github.com/springkim/FasterRCNN_SpringEdition/tree/master/CNTK/FasterRCNN). |
| 13 | +This file can download **VGG16_ImageNet_Caffe.model** . because our **FasterRCNN** use **VGG16** instead of **Alexnet**. |
| 14 | + |
| 15 | +And move to [CNTK/FasterRCNN/bin](https://github.com/springkim/FasterRCNN_SpringEdition/tree/master/CNTK/FasterRCNN/bin) and run **download_runfile.bat**. |
| 16 | +This file download **FasterRCNN_Train_SE.exe** and dependency dlls. |
| 17 | + |
| 18 | +**FasterRCNN_train_SE.exe** needs 1 integer argument. This argument is epoch for train. |
| 19 | +The example run script is in [CNTK/FasterRCNN/](https://github.com/springkim/FasterRCNN_SpringEdition/tree/master/CNTK/FasterRCNN)**train.bat**. |
| 20 | + |
| 21 | +#### 2. Train our own data format and location. |
| 22 | + |
| 23 | +Actually, **FasterRCNN_Train_SE.exe** read only two files. first one is `../train_img_file.txt`, Second one is `../train_roi_file.txt`. That's why i made **FasterRCNN_Train_SE.exe** in **bin** folder. |
| 24 | + |
| 25 | +This format follows the [Microsoft/CNTK](https://github.com/Microsoft/CNTK) format. |
| 26 | + |
| 27 | +`train_img_file.txt` follows the format below. |
| 28 | +``` |
| 29 | +0 <image-path> 0 |
| 30 | +1 <image-path> 0 |
| 31 | +2 <image-path> 0 |
| 32 | +``` |
| 33 | +First column is number of image. Second column is image path. Last column must be zero. |
| 34 | +You can see [CNTK/FasterRCNN/train_img_file.txt](https://github.com/springkim/FasterRCNN_SpringEdition/blob/master/CNTK/FasterRCNN/train_img_file.txt) for understand. |
| 35 | +`train_roi_file.txt` follows the format below. |
| 36 | +``` |
| 37 | +0 |roiAndLabel <x1 y1 x2 y2 class> |
| 38 | +1 |roiAndLabel <x1 y1 x2 y2 class> <x1 y1 x2 y2 class> |
| 39 | +``` |
| 40 | +First column is number of image~~(stupid format)~~, Second column must be `|roiAndLabel` ,Third column is coordinate of object. You can write multiple coordinate of object in same line. |
| 41 | + |
| 42 | +Finally, It looks like below. |
| 43 | +``` |
| 44 | +┌ bin |
| 45 | +│ ├ FasterRCNN_Train_SE.exe |
| 46 | +│ └ <Requirement dlls> |
| 47 | +├ img |
| 48 | +│ └ <images that wrote in train_img_file.txt> |
| 49 | +├ train_img_file.txt |
| 50 | +├ train_roi_file.txt |
| 51 | +└ train.bat |
| 52 | +``` |
| 53 | +Now you can run **train.bat** for trainning. |
| 54 | + |
| 55 | +model file will generate at the same location. |
| 56 | + |
| 57 | +## Setup for detect |
| 58 | +#### 1. Download pre-trained model and files. |
| 59 | +Run both **download_detect_exe.bat** and **download_pretrained_model.bat** in the [FasterRCNN_SE_Detection_Example](https://github.com/springkim/FasterRCNN_SpringEdition/tree/master/FasterRCNN_SE_Detection_Example). |
| 60 | + |
| 61 | +#### 2. Run. |
| 62 | + |
| 63 | +And open **FasterRCNN_SE_Detection_Example.sln** as [Visual Studio 2015](https://www.visualstudio.com/ko/downloads/?rr=https%3A%2F%2Fwww.google.co.kr%2F).~~(Maybe it works on VS2013 and VS2017 too)~~ |
| 64 | + |
| 65 | +We needs only 1 header file**(FasterRCNN_SE.h)** for detect. Of course your exe file needs **FasterRCNN_Detect_SE.exe** and requirement dlls(22 files). |
| 66 | + |
| 67 | +Model loading time is about 20~30s. |
| 68 | + |
| 69 | +## Technical issue. |
| 70 | +The [CNTK](https://github.com/Microsoft/CNTK) is python wrapper. They support C++ interface. But it works only in CPU to detection. |
| 71 | + |
| 72 | +[CPU version detection](https://github.com/springkim/FasterRCNN_SpringEdition/blob/master/dev/CNTK- |
| 73 | +eval-CPU-only.cpp) |
| 74 | + |
| 75 | +I have to run this code on C++ without Python dependencies. |
| 76 | + |
| 77 | +So, I used IPC with python executable file. I used [pyinstaller](http://www.pyinstaller.org/) for make exe file. |
| 78 | + |
| 79 | +Finally, It does not support GPU SLI. |
| 80 | + |
| 81 | +I tested it on (Windows10,GTX1080) and (windows10,TITAN X). |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
5 | 88 |
|
0 commit comments