通过端到端GPU优化的快速准确的单阶段对象检测。
ODTK是一个具有各种骨架和检测头的单射击对象检测器。这允许性能/准确性权衡。
它经过优化用于端到端GPU处理:
现在,此存储库支持旋转的边界框检测。有关如何使用--rotated-bbox命令,请参见旋转的检测训练和旋转检测推理文档。
边界框注释由[x, y, w, h, theta]描述。
检测管道允许用户根据延迟准确性权衡选择特定的主链。
经过完整的培训时间表后,ODTK视网膜模型的准确性和推理潜伏期和FPS(每秒帧)(火车/瓦尔)。推理结果包括批量尺寸为1的边界框,以1的批量处理。在fp16张力的发动机上使用--with-dali在--resize 800测量的推理。
| 骨干 | 地图 @[iou = 0.50:0.95] | DGX1V的培训时间 | V100的推理延迟fp16 | T4上的推理潜伏期INT8 | A100的推理延迟fp16 | A100上的推理潜伏期INT8 |
|---|---|---|---|---|---|---|
| resnet18fpn | 0.318 | 5小时 | 14 ms; 71 fps | 18 ms; 56 fps | 9 ms; 110 fps | 7 ms; 141 fps |
| Mobilenetv2fpn | 0.333 | 14 ms; 74 fps | 18 ms; 56 fps | 9 ms; 114 fps | 7 ms; 138 fps | |
| resnet34fpn | 0.343 | 6小时 | 16 ms; 64 fps | 20毫秒; 50 fps | 10 ms; 103 fps | 7 ms; 142 fps |
| RESNET50FPN | 0.358 | 7小时 | 18 ms; 56 fps | 22 ms; 45 fps | 11 ms; 93 fps | 8 ms; 129 fps |
| resnet101fpn | 0.376 | 10小时 | 22 ms; 46 fps | 27 ms; 37 fps | 13 ms; 78 fps | 9 ms; 117 fps |
| resnet152fpn | 0.393 | 12小时 | 26 ms; 38 fps | 33毫秒; 31 fps | 15 ms; 66 fps | 10 ms; 103 fps |
为了获得最佳性能,请使用最新的Pytorch NGC Docker容器。克隆此存储库,构建并运行您自己的图像:
git clone https://github.com/nvidia/retinanet-examples
docker build -t odtk:latest retinanet-examples/
docker run --gpus all --rm --ipc=host -it odtk:latest可以通过odtk实用程序来完成培训,推理,评估和模型导出。有关更多详细信息,包括参数列表,请参阅培训和推理文档。
从预训练的骨干链上训练2017年可可2017的检测模型:
odtk train retinanet_rn50fpn.pth --backbone ResNet50FPN
--images /coco/images/train2017/ --annotations /coco/annotations/instances_train2017.json
--val-images /coco/images/val2017/ --val-annotations /coco/annotations/instances_val2017.json微调数据集中的预训练模型。在下面的示例中,我们将Pascal VOC和JSON注释:
odtk train model_mydataset.pth --backbone ResNet50FPN
--fine-tune retinanet_rn50fpn.pth
--classes 20 --iters 10000 --val-iters 1000 --lr 0.0005
--resize 512 --jitter 480 640 --images /voc/JPEGImages/
--annotations /voc/pascal_train2012.json --val-annotations /voc/pascal_val2012.json注意:只要较长的侧面不大于max-size ,输入图像的较短侧将调整resize 。在训练过程中,图像将随机调整到jitter范围内的新尺寸。
在2017年可可评估您的检测模型:
odtk infer retinanet_rn50fpn.pth --images /coco/images/val2017/ --annotations /coco/annotations/instances_val2017.json在数据集上运行推断:
odtk infer retinanet_rn50fpn.pth --images /dataset/val --output detections.json为了更快的推断,请将检测模型导出到优化的FP16张力引擎:
odtk export model.pth engine.plan用Tensorrt后端在2017年使用Tensorrt后端评估模型:
odtk infer engine.plan --images /coco/images/val2017/ --annotations /coco/annotations/instances_val2017.json为了更快的推断,请执行INT8校准以创建优化的INT8 Tensorrt引擎:
odtk export model.pth engine.plan --int8 --calibration-images /coco/images/val2017/这将创建一个可用于INT8CALIBRATIONT的文件,该文件可用于以后为同一型号创建INT8 Tensorrt引擎而无需进行校准。
或使用缓存的校准表创建优化的INT8张力发动机:
odtk export model.pth engine.plan --int8 --calibration-table /path/to/INT8CalibrationTable视网膜支持可可JSON格式的注释。将注释从您自己的数据集转换为JSON时,需要以下条目:
{
"images": [{
"id" : int,
"file_name" : str
}],
"annotations": [{
"id" : int,
"image_id" : int,
"category_id" : int,
"bbox" : [x, y, w, h] # all floats
"area": float # w * h. Required for validation scores
"iscrowd": 0 # Required for validation scores
}],
"categories": [{
"id" : int
]}
}
如果使用--rotated-bbox标志进行旋转检测,请在注释中添加额外的float theta 。要获得验证分数,您还需要填写segmentation部分。
"bbox" : [x, y, w, h, theta] # all floats, where theta is measured in radians anti-clockwise from the x-axis.
"segmentation" : [[x1, y1, x2, y2, x3, y3, x4, y4]]
# Required for validation scores.
这是一个研究项目,而不是官方的NVIDIA产品。
该分支使用Tensorrt 7。如果您使用Pytorch训练和推断模型,或者在Tesla GPU(例如V100,T4)上创建Tensorrt引擎,则应使用此分支。
如果您希望将模型部署到运行JetPack 4.3版的Jetson设备(例如-Jetson agx Xavier),则应使用此存储库的19.10分支。