#将模型参数转化为half
self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
self.half = self.device.type != 'cpu' # half precision only supported on CUDA
if self.half:
self.model.half() # to FP16
#输入设置为half
self.half=True
img = img.half() if self.half else img.float() # uint8 to fp16/32
实验表明,在行人检测推理的时候,加入半精度确实会减小显存的开销,但推理的时间好像差不多。
half半精度
最新推荐文章于 2024-04-25 18:14:07 发布