# Bacteria Detection
![Pipeline](examples/.resources/pipeline.gif)
The goal of the project is to get the bacteria count from multiple continuously pictured frames for a single area. Currently, the best results in terms of time and accuracy are with [YOLOv5 object detection model](https://github.com/ultralytics/yolov5).
## How to use
To run the detection, type the following command:
> `python3 detect.py --source SOURCE [--engine ENGINE] [--frame-weights FRAME_WEIGHTS] [--conf-thres CONF_THRES] [--iou-thres IOU_THRES] [--agc-distance AGC_DISTANCE] [--out-path OUT_PATH] [--save-results]`
- `--source SOURCE` : Path to the folder of images for detection (should be either a single folder, or a folder that contains multiple folders with images)
- `--engine ENGINE` : The path to the engine file
- `--frame-weights FRAME_WEIGHTS` : Path to the frame weights
- `--conf-thres CONF_THRES` : The minimum confidence threshold for the detections
- `--iou-thres IOU_THRES` : The IOU threshold for YOLO NMS
- `--agc-distance AGC_DISTANCE` : The maximum distance between elements of cluster for bacteria
- `--out-path OUT_PATH` : The root directory where the results will be saved
- `--save-results` : If option is selected the mip with detections on it, detected boxes and detection time info will be saved.
## Example
> `python3 detect.py --source examples/test_data/images --save-results --out_path examples/test_data/detection`
## Requirements
If one of these scripts was not run before, run the one with a compatible version of Nvidia-Jetpack on your device.
- `setup_JDK_Nano_4.5.1-b17.sh`
- `setup_JDK_Nano_4.6.1-b110.sh`
A command to check the Jetpack version of your device:
> `sudo apt-cache show nvidia-jetpack`
Otherwise, run the following command as a super-user (**sudo**)
> `pip install -r requirements.txt && path5='export LD_PRELOAD={$LD_PRELOAD}:"/usr/local/lib/python3.6/dist-packages/scikit_learn.libs/libgomp-d22c30c5.so.1.0.0"' && echo "$path5" >> ~/.bashrc`
## Project's Pipeline
**Data**
- There were many microscope folders, each containing around 238 images with contiguous focal depth for a single area.
**Main Pipeline**
- The data was not labeled, and to fix it, different methods were tried:
1. **Classic algorithm with OpenCV** to find the bright areas(possibly bacteria) in the MIP(Maximum Intensity Projection). Then the boxes of those areas were used as labels for modified YOLOv5(to get as an input 20 channel patches). With this method, the results were not promising.
2. Create a '[**Custom classification CNN**](https://gitlab.com/sven.badalyan/testo_jetson/-/tree/main)' which will determine if the selected box is a bacteria or not. Frame detection(the algorithm with OpenCV) results were used as labels for the training of the net. The network takes as an input crops of bacteria, and for each crop, returns 1 if a crop is determined as a bacterium and 0 otherwise. The results with this approach have a lot higher accuracy, but for some bright areas, the model gives wrong predictions.![Frame Detection + Custom CNN](examples/.resources/CNN.png)<br><br>
3. Create a '[**Combined model (CNN+Dense)**](https://gitlab.com/sven.badalyan/testo_jetson/-/tree/local_mip_density_std_branch)' which will take the density scores and a crop for each area proposed by the frame detection and according to those classify whether the crop is a bacteria or not. A new custom small DenseNet was merged with the classification CNN. The results are very good, many of the previous major errors were eliminated but still, frame detection has limits for detecting multiple bacteria which are stitched together, as it takes them as a single area. ![Frame Detection + Combined Model](examples/.resources/Combined.png)<br><br>
4. **Use YOLOv5**
1. **Train YOLOv5** with its augmentations. Use the combined model for generating good labels. Filter the frames where boxes big area exists (those boxes are mostly the ones that contain multiple bacteria), so that wrong data is not fed to the YOLOv5s. After the above steps, YOLOv5 started to detect bacteria better and better, as the data was cleaned up. When the results were satisfying, enough optimizations were needed for the model to work on Jetson Nano as fast as possible.
2. Train **YOLOv5(nano)**. Convert the trained model into a **TensorRT** engine for speed-up. Create a script for detecting bacteria frame-by-frame and merge detection on all frames correctly, without losing stitched bacteria. For that purpose, Agglomerative Clustering is used.![YOLOv5](examples/.resources/Yolov5.png)<br><br>
## Comparisons
![Time Comparison](examples/.resources/time.png)<br><br>
From the above comparison, we can see that with YOLO_v5 TensorRT, the detection is a lot faster than with the previous approaches. In addition to that, YOLOv5 has a huge potential to detect stitched bacteria. Below you can see the comparison between previous models and YOLOv5_TRT.
<br><br>![Detection Comparison](examples/.resources/comparison.png)
<br><br>![Detection Comparison](examples/.resources/metrics.png)
没有合适的资源?快使用搜索试试~ 我知道了~
基于 YOLOv5 的 Jetson Nano 细菌检测
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共15个文件
png:6个
py:3个
txt:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 87 浏览量
2024-05-20
20:41:27
上传
评论
收藏 42.75MB ZIP 举报
温馨提示
若要运行检测,请键入以下命令: python3 detect.py --source SOURCE [--engine ENGINE] [--frame-weights FRAME_WEIGHTS] [--conf-thres CONF_THRES] [--iou-thres IOU_THRES] [--agc-distance AGC_DISTANCE] [--out-path OUT_PATH] [--save-results] --source SOURCE:用于检测的图像文件夹的路径(应为单个文件夹,或包含多个包含图像的文件夹的文件夹) --engine ENGINE:引擎文件的路径 --frame-weights FRAME_WEIGHTS:帧权重的路径 --conf-thres CONF_THRES:检测的最小置信度阈值 --iou-thres IOU_THRES:YOLO NMS 的 IOU 阈值 --agc-distance AGC_DISTANCE:细菌簇元素之间的最大距离 --out-path OUT_PATH:保存结果的根目录 --save-results:如
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/TXT.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 15 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
hakesashou
- 粉丝: 5180
- 资源: 1541
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- C# winform置托盘图标并闪烁演示源码.zip
- 打包和分发Rust工具.pdf
- SQL中的CREATE LOGFILE GROUP 语句.pdf
- C语言-leetcode题解之第172题阶乘后的零.zip
- C语言-leetcode题解之第171题Excel列表序号.zip
- C语言-leetcode题解之第169题多数元素.zip
- ocr-图像识别资源ocr-图像识别资源
- 图像识别:基于Resnet50 + VGG16模型融合的人体细胞癌症分类模型实现-图像识别资源
- C语言-leetcode题解之第168题Excel列表名称.zip
- C语言-leetcode题解之第167题两数之和II-输入有序数组.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)