博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MXNet学习:预测结果-识别单张图片
阅读量:6981 次
发布时间:2019-06-27

本文共 819 字,大约阅读时间需要 2 分钟。

用到了model里的FeedForward.load和predict

import osimport mxnet as mximport numpy as npimport Imagefrom collections import namedtupleBatch = namedtuple('Batch',['data'])synsets = [0,1,2,3,4,5,6,7,8,9]def predict(img_url,model,synsets):    img = Image.open(img_url)    img = img.convert('L')    img = img.resize((28,28),Image.ANTIALIAS)    img.save(img_url)    img = np.asarray(img,dtype=np.uint8)    img = img.reshape(1,1,28,28).astype(np.float32)/255    val = mx.io.NDArrayIter(data=img)    res =  model.predict(X=val)[0]    for i in range(0,10):        print "%d: %.2f" % (synsets[i],res[i])model = mx.model.FeedForward.load('MNIST_MXNet',100)while(1):    img_url = raw_input("Enter the img_url: ")    predict(img_url,model,synsets)

save时用到的是 model.save('MNIST_MXNet',100) 

转载于:https://www.cnblogs.com/Mu001999/p/6221104.html

你可能感兴趣的文章
寻湖北荆州刘氏族谱
查看>>
Oracle数据库的DBID变更
查看>>
MagicLinux+MySQL5+PHP5+Apache2+phpMyAdmin
查看>>
服务器RAID磁盘坏道修复实战
查看>>
SOAP
查看>>
Sql Server 2005 基于通知的缓存失效
查看>>
理解Windows中的路由表和默认网关
查看>>
.NET多线程编程(13)——一个简单的C#多线程间同步的例子
查看>>
mysql数据导入中文乱码的解决办法
查看>>
Exception和Error分析(—)—UnsatisfiedLinkError
查看>>
VMM系列之使用VMM服务器构建Hyper-V主机(1)
查看>>
cdh4.6.0到cdh5.2.0 upgrade和rollback问题小结
查看>>
MalformedInputException处理
查看>>
OPENAPI的测试用例编写方法
查看>>
在Windows Server 2008 R2上安装 PowerShell 5.0
查看>>
事件通知(Event Notification)实践
查看>>
快速构建Windows 8风格应用28-临时应用数据
查看>>
DVWA系列之12 利用Burpsuite进行暴力破解
查看>>
华为VRRP(不同vlan之间的冗余备份)
查看>>
单片机数码管码段
查看>>