Unverified 提交 b31229ae authored 作者: edificewang's avatar edificewang 提交者: GitHub

Revert FP16 `test.py` and `detect.py` inference to FP32 default (#3423)

* fixed inference bug ,while use half precision * replace --use-half with --half * replace space and PEP8 in detect.py * PEP8 detect.py * update --half help comment * Update test.py * revert space Co-authored-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com>
上级 044daafd
...@@ -28,7 +28,7 @@ def detect(opt): ...@@ -28,7 +28,7 @@ def detect(opt):
# Initialize # Initialize
set_logging() set_logging()
device = select_device(opt.device) device = select_device(opt.device)
half = device.type != 'cpu' # half precision only supported on CUDA half = opt.half and device.type != 'cpu' # half precision only supported on CUDA
# Load model # Load model
model = attempt_load(weights, map_location=device) # load FP32 model model = attempt_load(weights, map_location=device) # load FP32 model
...@@ -172,6 +172,7 @@ if __name__ == '__main__': ...@@ -172,6 +172,7 @@ if __name__ == '__main__':
parser.add_argument('--line-thickness', default=3, type=int, help='bounding box thickness (pixels)') parser.add_argument('--line-thickness', default=3, type=int, help='bounding box thickness (pixels)')
parser.add_argument('--hide-labels', default=False, action='store_true', help='hide labels') parser.add_argument('--hide-labels', default=False, action='store_true', help='hide labels')
parser.add_argument('--hide-conf', default=False, action='store_true', help='hide confidences') parser.add_argument('--hide-conf', default=False, action='store_true', help='hide confidences')
parser.add_argument('--half', type=bool, default=False, help='use FP16 half-precision inference')
opt = parser.parse_args() opt = parser.parse_args()
print(opt) print(opt)
check_requirements(exclude=('tensorboard', 'pycocotools', 'thop')) check_requirements(exclude=('tensorboard', 'pycocotools', 'thop'))
......
...@@ -306,6 +306,7 @@ if __name__ == '__main__': ...@@ -306,6 +306,7 @@ if __name__ == '__main__':
parser.add_argument('--project', default='runs/test', help='save to project/name') parser.add_argument('--project', default='runs/test', help='save to project/name')
parser.add_argument('--name', default='exp', help='save to project/name') parser.add_argument('--name', default='exp', help='save to project/name')
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment') parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
parser.add_argument('--half', type=bool, default=False, help='use FP16 half-precision inference')
opt = parser.parse_args() opt = parser.parse_args()
opt.save_json |= opt.data.endswith('coco.yaml') opt.save_json |= opt.data.endswith('coco.yaml')
opt.data = check_file(opt.data) # check file opt.data = check_file(opt.data) # check file
...@@ -326,6 +327,7 @@ if __name__ == '__main__': ...@@ -326,6 +327,7 @@ if __name__ == '__main__':
save_txt=opt.save_txt | opt.save_hybrid, save_txt=opt.save_txt | opt.save_hybrid,
save_hybrid=opt.save_hybrid, save_hybrid=opt.save_hybrid,
save_conf=opt.save_conf, save_conf=opt.save_conf,
half_precision=opt.half,
opt=opt opt=opt
) )
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论