Add paddle.no_grad in predict()
@@ -92,6 +92,7 @@ class ImageClassifierModule(RunModule, ImageServing):
results(list[dict]) : The prediction result of each input image
'''
self.eval()
+ with paddle.no_grad():
res = []
total_num = len(images)
loop_num = int(np.ceil(total_num / batch_size))
@@ -223,6 +224,7 @@ class ImageColorizeModule(RunModule, ImageServing):
res(list[dict]) : The prediction result of each input image
'''
self.eval()
+ with paddle.no_grad():
lab2rgb = T.LAB2RGB()
res = []
total_num = len(images)
@@ -393,6 +395,7 @@ class Yolov3Module(RunModule, ImageServing):
labels(np.ndarray): Predict labels.
'''
self.eval()
+ with paddle.no_grad():
boxes = []
scores = []
self.downsample = 32
@@ -521,6 +524,7 @@ class StyleTransferModule(RunModule, ImageServing):
output(list[np.ndarray]) : The style transformed images with bgr mode.
'''
self.eval()
+ with paddle.no_grad():
style = paddle.to_tensor(self.transform(style).astype('float32'))
style = style.unsqueeze(0)
@@ -655,6 +659,7 @@ class ImageSegmentationModule(ImageServing, RunModule):
output(list[np.ndarray]) : The segmentation mask.
'''
self.eval()
+ with paddle.no_grad():
result = []
total_num = len(images)
