mirror of
https://github.com/ultralytics/yolov5.git
synced 2025-06-03 14:49:29 +08:00
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: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
044daafd9d
commit
b31229ae89
@ -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__':
|
|||||||
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'))
|
||||||
|
2
test.py
2
test.py
@ -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__':
|
|||||||
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
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user