Revert FP16 `test.py` and `detect.py` inference to FP32 default (#3423)
Browse files* 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: Glenn Jocher <[email protected]>
detect.py
CHANGED
@@ -28,7 +28,7 @@ def detect(opt):
|
|
28 |
# Initialize
|
29 |
set_logging()
|
30 |
device = select_device(opt.device)
|
31 |
-
half = device.type != 'cpu' # half precision only supported on CUDA
|
32 |
|
33 |
# Load model
|
34 |
model = attempt_load(weights, map_location=device) # load FP32 model
|
@@ -172,6 +172,7 @@ if __name__ == '__main__':
|
|
172 |
parser.add_argument('--line-thickness', default=3, type=int, help='bounding box thickness (pixels)')
|
173 |
parser.add_argument('--hide-labels', default=False, action='store_true', help='hide labels')
|
174 |
parser.add_argument('--hide-conf', default=False, action='store_true', help='hide confidences')
|
|
|
175 |
opt = parser.parse_args()
|
176 |
print(opt)
|
177 |
check_requirements(exclude=('tensorboard', 'pycocotools', 'thop'))
|
|
|
28 |
# Initialize
|
29 |
set_logging()
|
30 |
device = select_device(opt.device)
|
31 |
+
half = opt.half and device.type != 'cpu' # half precision only supported on CUDA
|
32 |
|
33 |
# Load model
|
34 |
model = attempt_load(weights, map_location=device) # load FP32 model
|
|
|
172 |
parser.add_argument('--line-thickness', default=3, type=int, help='bounding box thickness (pixels)')
|
173 |
parser.add_argument('--hide-labels', default=False, action='store_true', help='hide labels')
|
174 |
parser.add_argument('--hide-conf', default=False, action='store_true', help='hide confidences')
|
175 |
+
parser.add_argument('--half', type=bool, default=False, help='use FP16 half-precision inference')
|
176 |
opt = parser.parse_args()
|
177 |
print(opt)
|
178 |
check_requirements(exclude=('tensorboard', 'pycocotools', 'thop'))
|
test.py
CHANGED
@@ -306,6 +306,7 @@ if __name__ == '__main__':
|
|
306 |
parser.add_argument('--project', default='runs/test', help='save to project/name')
|
307 |
parser.add_argument('--name', default='exp', help='save to project/name')
|
308 |
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
|
|
|
309 |
opt = parser.parse_args()
|
310 |
opt.save_json |= opt.data.endswith('coco.yaml')
|
311 |
opt.data = check_file(opt.data) # check file
|
@@ -326,6 +327,7 @@ if __name__ == '__main__':
|
|
326 |
save_txt=opt.save_txt | opt.save_hybrid,
|
327 |
save_hybrid=opt.save_hybrid,
|
328 |
save_conf=opt.save_conf,
|
|
|
329 |
opt=opt
|
330 |
)
|
331 |
|
|
|
306 |
parser.add_argument('--project', default='runs/test', help='save to project/name')
|
307 |
parser.add_argument('--name', default='exp', help='save to project/name')
|
308 |
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
|
309 |
+
parser.add_argument('--half', type=bool, default=False, help='use FP16 half-precision inference')
|
310 |
opt = parser.parse_args()
|
311 |
opt.save_json |= opt.data.endswith('coco.yaml')
|
312 |
opt.data = check_file(opt.data) # check file
|
|
|
327 |
save_txt=opt.save_txt | opt.save_hybrid,
|
328 |
save_hybrid=opt.save_hybrid,
|
329 |
save_conf=opt.save_conf,
|
330 |
+
half_precision=opt.half,
|
331 |
opt=opt
|
332 |
)
|
333 |
|