提交 1bed29c3 编写于 作者: H haoyuying

revise transform and pascalvoc dataset

上级 e8fb682f
...@@ -26,8 +26,8 @@ from PIL import Image ...@@ -26,8 +26,8 @@ from PIL import Image
from paddlehub.module.module import serving, RunModule from paddlehub.module.module import serving, RunModule
from paddlehub.utils.utils import base64_to_cv2 from paddlehub.utils.utils import base64_to_cv2
from paddlehub.process.transforms import ConvertColorSpace, ColorPostprocess, Resize import paddlehub.process.transforms as T
from paddlehub.process.functional import subtract_imagenet_mean_batch, gram_matrix, draw_boxes_on_image, img_shape import paddlehub.process.functional as Func
class ImageServing(object): class ImageServing(object):
...@@ -135,8 +135,8 @@ class ImageColorizeModule(RunModule, ImageServing): ...@@ -135,8 +135,8 @@ class ImageColorizeModule(RunModule, ImageServing):
visual_ret = OrderedDict() visual_ret = OrderedDict()
psnrs = [] psnrs = []
lab2rgb = ConvertColorSpace(mode='LAB2RGB') lab2rgb = T.ConvertColorSpace(mode='LAB2RGB')
process = ColorPostprocess() process = T.ColorPostprocess()
for i in range(batch[0].numpy().shape[0]): for i in range(batch[0].numpy().shape[0]):
real = lab2rgb(np.concatenate((batch[0].numpy(), batch[3].numpy()), axis=1))[i] real = lab2rgb(np.concatenate((batch[0].numpy(), batch[3].numpy()), axis=1))[i]
visual_ret['real'] = process(real) visual_ret['real'] = process(real)
...@@ -160,9 +160,9 @@ class ImageColorizeModule(RunModule, ImageServing): ...@@ -160,9 +160,9 @@ class ImageColorizeModule(RunModule, ImageServing):
Returns: Returns:
results(list[dict]) : The prediction result of each input image results(list[dict]) : The prediction result of each input image
''' '''
lab2rgb = ConvertColorSpace(mode='LAB2RGB') lab2rgb = T.ConvertColorSpace(mode='LAB2RGB')
process = ColorPostprocess() process = T.ColorPostprocess()
resize = Resize((256, 256)) resize = T.Resize((256, 256))
visual_ret = OrderedDict() visual_ret = OrderedDict()
im = self.transforms(images, is_train=False) im = self.transforms(images, is_train=False)
out_class, out_reg = self(paddle.to_tensor(im['A']), paddle.to_variable(im['hint_B']), out_class, out_reg = self(paddle.to_tensor(im['A']), paddle.to_variable(im['hint_B']),
...@@ -263,7 +263,7 @@ class Yolov3Module(RunModule, ImageServing): ...@@ -263,7 +263,7 @@ class Yolov3Module(RunModule, ImageServing):
scores = [] scores = []
self.downsample = 32 self.downsample = 32
im = self.transform(imgpath) im = self.transform(imgpath)
h, w, c = img_shape(imgpath) h, w, c = Func.img_shape(imgpath)
im_shape = paddle.to_tensor(np.array([[h, w]]).astype('int32')) im_shape = paddle.to_tensor(np.array([[h, w]]).astype('int32'))
label_names = self.get_label_infos(filelist) label_names = self.get_label_infos(filelist)
img_data = paddle.to_tensor(np.array([im]).astype('float32')) img_data = paddle.to_tensor(np.array([im]).astype('float32'))
...@@ -306,6 +306,6 @@ class Yolov3Module(RunModule, ImageServing): ...@@ -306,6 +306,6 @@ class Yolov3Module(RunModule, ImageServing):
boxes = bboxes[:, 2:].astype('float32') boxes = bboxes[:, 2:].astype('float32')
if visualization: if visualization:
draw_boxes_on_image(imgpath, boxes, scores, labels, label_names, 0.5) Func.draw_boxes_on_image(imgpath, boxes, scores, labels, label_names, 0.5)
return boxes, scores, labels return boxes, scores, labels
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册