predict module

class predict.GluonNet(model_path, alphabet, img_shape, net, img_channel=3, gpu_id=None)[源代码]

基类:object

__init__(model_path, alphabet, img_shape, net, img_channel=3, gpu_id=None)[源代码]

初始化gluon模型 :param model_path: 模型地址 :param alphabet: 字母表 :param img_shape: 图像的尺寸(w,h) :param net: 网络计算图,如果在model_path中指定的是参数的保存路径,则需要给出网络的计算图 :param img_channel: 图像的通道数: 1,3 :param gpu_id: 在哪一块gpu上运行

pre_processing(img_path)[源代码]

对图片进行处理,先按照高度进行resize,resize之后如果宽度不足指定宽度,就补黑色像素,否则就强行缩放到指定宽度 :param img_path: 图片地址 :return:

predict(img_path)[源代码]

对传入的图像进行预测,支持图像地址和numpy数组 :param img_path: 图像地址 :return:

predict.decode(preds, alphabet, raw=False)[源代码]
predict.try_gpu(gpu)[源代码]

If GPU is available, return mx.gpu(0); else return mx.cpu()