#! /usr/bin/env python # coding: utf-8 import os, sys import numpy as np import cv2 as cv import mxnet as mx from mxnet.model import BatchEndParam sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) from eval.evaluator import EvalParams, Evaluator from logger.logger_v1 import LogHandler logging = LogHandler() import utils.cv_show as CVShow def cv_save_lm_rets(datas, predi, labeli, prefix, num_count=0): if isinstance(datas, mx.nd.NDArray): datas = datas.as_in_context(mx.cpu()).asnumpy() if isinstance(predi, mx.nd.NDArray): predi = predi.as_in_context(mx.cpu()).asnumpy() if isinstance(labeli, mx.nd.NDArray): labeli = labeli.as_in_context(mx.cpu()).asnumpy() images = CVShow.cv_draw_batch_points(datas, predi * 64, color=(255, 0, 0)) images = np.stack([image.get().transpose((2, 0, 1)) for image in images], axis=0) images = CVShow.cv_draw_batch_points(images, labeli, normalized=False, color=(0, 0, 255)) for image in images: image_file = prefix + f"{num_count:06d}.jpg" image = cv.cvtColor(image, cv.COLOR_RGB2BGR)
def __init__(self, name='MobileNetV20Transform', logger=LogHandler()): super(MobileNetV20Transform, self).__init__(name) self.name = name self.logging = logger