愿你 发表于 2020-3-20 15:09:29

导入keras训练好的模型报错Unable to open file (Unable to open file: name = 'mo...

在django的视图中有如下代码

愿你 发表于 2020-3-20 15:13:10


from django.shortcuts import render
from .models import PicTest
# Create your views here.
from django.conf import settings
from .python_LPR import demo

def show_upload(request):
    """显示上传页面"""
    return render(request, 'myApp/upload_pic.html')

def upload_handle(request):
    """上传图片处理"""
    # 1.获取上传图片对象
    pic = request.FILES['pic']
    # print(type(pic))

    # 2.创建一个文件
    save_path = '%s/img/%s'%(settings.MEDIA_ROOT,pic.name)
    with open(save_path,'wb') as f:
         # 3.获取上传文件的内容并写到创建的文件中
      for content in pic.chunks():
            f.write(content)

    str = demo.recognizeOneImage(save_path)
    print(str)
    print("00000000000000000")


    # 4.在数据库中保存上传记录
    PicTest.objects.create(goods_pic='img/%s'%pic.name)
    # 5.返回
    return render(request, 'myApp/index.html')


在upload_handle函数中用到了另外一个py文件,该文件用keras训练好的模型可提取出车牌。
可是在浏览器输入网址时,却报错Exception Value:       
Unable to open file (Unable to open file: name = 'model/model12.h5', errno = 2, error message = 'no such file or directory', flags = 0, o_flags = 0)
Exception Location:        D:\Anaconda\lib\site-packages\h5py\_hl\files.py in make_fid, line 92

有遇到过的朋友还请赐教赐教呀!!{:10_297:}{:10_297:}
页: [1]
查看完整版本: 导入keras训练好的模型报错Unable to open file (Unable to open file: name = 'mo...