|
| 1 | +# Detectron2 pipeline |
| 2 | + |
| 3 | +Modular image processing pipeline using OpenCV and Python generators powered by [Detectron2](https://github.com/facebookresearch/detectron2). |
| 4 | + |
| 5 | +For detailed description how to construct image processing pipeline using OpenCV and Python generators |
| 6 | +read the following Medium stories in order: |
| 7 | +* [Modular image processing pipeline using OpenCV and Python generators](https://medium.com/deepvisionguru/modular-image-processing-pipeline-using-opencv-and-python-generators-9edca3ccb696) |
| 8 | +* [Video processing pipeline with OpenCV](https://medium.com/deepvisionguru/video-processing-pipeline-with-opencv-ac10187d75b) |
| 9 | +* How to embed Detectron2 in your computer vision project |
| 10 | + |
| 11 | +## Setup environment |
| 12 | + |
| 13 | +This project is using [Conda](https://conda.io) for project environment management. |
| 14 | + |
| 15 | +Setup the project environment: |
| 16 | + |
| 17 | + $ conda env create -f environment.yml |
| 18 | + $ conda activate detectron2-pipeline |
| 19 | + |
| 20 | +or update the environment if you `git pull` the repo previously: |
| 21 | + |
| 22 | + $ conda env update -f environment.yml |
| 23 | + |
| 24 | +Install Detectron2 in a folder one level above the `detectron2-pipeline` project folder |
| 25 | + |
| 26 | + $ cd .. |
| 27 | + $ git clone https://github.com/facebookresearch/detectron2.git |
| 28 | + $ cd detectron2 |
| 29 | + $ git checkout 3def12bdeaacd35c6f7b3b6c0097b7bc31f31ba4 |
| 30 | + $ python setup.py build develop |
| 31 | + |
| 32 | +We checkout `3def12bdeaacd35c6f7b3b6c0097b7bc31f31ba4` commit to ensure that you can use the code |
| 33 | +out of the box with this repo. |
| 34 | + |
| 35 | +If you got any problems with Detectron2 installation please refer to |
| 36 | +[INSTALL.md](https://github.com/facebookresearch/detectron2/blob/3def12bdeaacd35c6f7b3b6c0097b7bc31f31ba4/INSTALL.md). |
| 37 | + |
| 38 | +## Demo |
| 39 | + |
| 40 | +Run the command to execute inferences on images from the selected folder: |
| 41 | + |
| 42 | + $ python process_images.py -i assets/images/friends -p |
| 43 | + |
| 44 | +By default the instance segmentation model is used from `configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml`. |
| 45 | +You can try other models with `--config-file` option, for example: |
| 46 | + |
| 47 | + $ python process_images.py -i assets/images/friends -p --config-file configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml |
| 48 | + |
| 49 | +For video processing run: |
| 50 | + |
| 51 | + $ python process_video.py -i assets/videos/walk.small.mp4 -p -d -ov walk.small.mp4 |
| 52 | + |
| 53 | +## Tests |
| 54 | + |
| 55 | +`pytest` is used as a test framework. All tests are stored in `tests` folder. Run the tests: |
| 56 | + |
| 57 | +```bash |
| 58 | +$ pytest |
| 59 | +``` |
| 60 | + |
| 61 | +## Resources and Credits |
| 62 | + |
| 63 | +* For Unix like pipeline idea credits goes to this [Gist](https://gist.github.com/alexmacedo/1552724) |
| 64 | +* The source of the example images and videos is [pixbay](https://pixabay.com) |
| 65 | +* Some ideas and code snippets are borrowed from [pyimagesearch](https://www.pyimagesearch.com/) |
| 66 | +* Color constants from [Python Color Constants Module](https://www.webucator.com/blog/2015/03/python-color-constants-module/) |
| 67 | +* [Detectron2](https://github.com/facebookresearch/detectron2) |
| 68 | +* [Applications of Foreground-Background separation with Semantic Segmentation](https://www.learnopencv.com/applications-of-foreground-background-separation-with-semantic-segmentation/) |
| 69 | + |
| 70 | +## License |
| 71 | + |
| 72 | +[MIT License](LICENSE) |
0 commit comments