# SimplifiedSSD **Repository Path**: lonerlin/simplified-ssd ## Basic Information - **Project Name**: SimplifiedSSD - **Description**: 为SSD训练添加一个图形界面,用于简化SSD模型的训练。 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 3 - **Created**: 2021-04-10 - **Last Updated**: 2024-06-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 带图形界面的SSD目标检测 cpu,gpu均可使用 ## Requirements pytorch torchvision onnx pyqt boto3 pandas urllib3 ## 启动 运行 ssd_gui.py 启动图形界面。 ![0](https://gitee.com/lonerlin/simplified-ssd/raw/master/images/0.jpg) ## 数据准备 *** 如果你已经准备好数据集,请跳过这一步 *** ### 创建一个VOC2007文件夹 选择一个空的目录,点击“生成文件夹”生成VOC2007格式的文件夹 ![1](https://gitee.com/lonerlin/simplified-ssd/raw/master/images/1.jpg) ### 拍摄图像,打标签 *** 如果已经准备好图像的,直接把图像放到VOC2007文件夹下的JPEGImages目录下 *** ![2](https://gitee.com/lonerlin/simplified-ssd/raw/master/images/2.jpg) 1. 点击摄像头抓拍,打开摄像头,捕捉图像 ![3](https://gitee.com/lonerlin/simplified-ssd/raw/master/images/3.jpg) 2. 点击编辑标签类别,编辑标签,第一个标签为“BACKGROUND”,全部字母为大写。 ![4](https://gitee.com/lonerlin/simplified-ssd/raw/master/images/4.jpg) 3. 打开LabelImg,为图像打标签 ![5](https://gitee.com/lonerlin/simplified-ssd/raw/master/images/5.jpg) ## 模型训练 设置训练参数,保存参数,然后开始训练。 ![6](https://gitee.com/lonerlin/simplified-ssd/raw/master/images/6.jpg) 训练完成,训练结果保存在training_records中。 ![7](https://gitee.com/lonerlin/simplified-ssd/raw/master/images/7.jpg) ## 模型测试 选中训练完成的模型,选中标签文件,打开图像测试 ![8](https://gitee.com/lonerlin/simplified-ssd/raw/master/images/8.jpg) ## 导出模型 导出为ONNX模型,可以导出到Jetson nano上运行。 ![9](https://gitee.com/lonerlin/simplified-ssd/raw/master/images/9.jpg) ## 程序调用实例 以下程序演示了使用opencv调用摄像头进行目标检测 ```python import sys import cv2 sys.path.append("E:\simplified-ssd") # simplified-ssd文件夹所在路径 from prediction import Prediction #使用自己训练模型时使用以下代码 # model_path = "E:/simplified-ssd/models/mb1-ssd-Epoch-29-Loss-1.6614457368850708.pth" # label_path = "E:/dataset/cow_wolf/VOC2007/labels.txt" # pre = Prediction(model_path=model_path, label_path=label_path) # 使用默认的模型 pre = Prediction() # 摄像头 cap = cv2.VideoCapture(0) while True: ret, frame = cap.read() # 返回渲染过的图像(RGB),检测结果列表list(box,label,probs) image, results = pre(frame) if results: print(results) cv2.imshow("Test window", cv2.cvtColor(image, cv2.COLOR_RGB2BGR)) if cv2.waitKey(1) == ord('q'): break pre = None ``` ###注释 本项目是基于[jetson-inference](https://github.com/dusty-nv/jetson-inference/). 在原有项目的基础上添加了一个简单的图形界面,把大部分参数设置为默认。添加了数据处理处理部分,拍照小软件,模型测试,模型导出,训练结果记录与输出等简单功能。 同时,修改了部分程序,使训练和测试同时支持CPU,GUP。 This repo implements [SSD (Single Shot MultiBox Detector)](https://arxiv.org/abs/1512.02325) in PyTorch for object detection, using MobileNet backbones. It also has out-of-box support for retraining on Google Open Images dataset. > For documentation, please refer to Object Detection portion of the **[Hello AI World](https://github.com/dusty-nv/jetson-inference/tree/dev#training)** tutorial: > [Re-training SSD-Mobilenet](https://github.com/dusty-nv/jetson-inference/blob/dev/docs/pytorch-ssd.md) Thanks to @qfgaohao for the upstream implementation from: [https://github.com/qfgaohao/pytorch-ssd](https://github.com/qfgaohao/pytorch-ssd)