Skip to content

Module to perform strided inferencing using any pre-trained model to get the better and accurate results on high-resolution images.

License

Notifications You must be signed in to change notification settings

Bridgei2i/strided_inference

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Strided Inference: for small object detection in high resolution images

Header.png

Requirements

$ pip install -r requirements.txt

1. Using strided inference with a pre-trained model

>>> from strided_inference.strided_inference import strided_inference
>>> img_name = 'img.jpg'
>>> image = cv2.imread(f'images/{img_name}')

>>> detections = strided_inference(img, img_name, detector, tile_size_info=(900, 700, 701), nms_th=0.95)

2. To generate tiles for training new model

The key use case of this module is to make use of Strided Inferencing with a pre-trained model, yet for lot of cases there might be a need to train a new model on tiled images. We provide a submodule that performs this task and outputs tiled images and new tiled CSV(containing annotations) for your new model training.

>>> from tiler_with_annotations import tile_for_training
>>> ob = tile_for_training()
>>> ob.tiler_with_annotations(image_folder_path, annotation_csv_path,  output_directory_path, tile_size_information)

3. Example

We ran OpenCV's DNN module's object detection using our library to see the difference in the result. Please re-run the code in Trying_strided_inference.ipynb to get similar results. The model has to be downloaded from this link and put inside example/OpenCV DNN folder before running the notebook.

Below we can see results of using OpenCV’s DNN module’s ssd_mobilenet network object detection with and without strided inference:

Figure 1: Stock image(5306 x 2985) of a substation with a big crowd

Original Stock Image

Figure 2: Result of running object detector with low confidence

Original Stock Image

Figure 3: Detections using strided inference using 900 pixel tiles and NMS of 0.95

Original Stock Image

Acknowledgement

This code base is partially based on a brilliant paper published in CVF. We sincerely would like to thank Unel, Ozkalaycı and Cıgla for their work.

Author

  • Amit Amola LinkedIn, Github

    @amit_amola is the current maintainer of the code and has written much of the current code base, including a complete refactor of the core for open source version. He has been part of Bridgei2i since 2018 and currently works as Senior Analytics Consultant at AI Labs.

  • Anil Prasad MN Google Scholar, LinkedIn, Github

    The project was carried under supervision and guidance of @anilprasadmn. He currently works as Manager AI labs at BRIDGEi2i Analytics Solutions.

Queries and contribution

If someone has any queries, one can connect to us via email- [email protected]
Feel free to contribute to the project and raise pull request for the same.

About

Module to perform strided inferencing using any pre-trained model to get the better and accurate results on high-resolution images.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published