在Django添加深度学习模型

时间:2020-09-17 00:43:33

标签: python django pytorch

ml:django应用程序文件夹 测试:pytorch python代码文件夹--predict.py(model)

我想使用我在predcit.py在views.py上创建的procees函数

处理功能

def process():
for img_file in os.listdir('C:\\Users\\user\\Desktop\\model\\project\\ml\\test\\images'):

    img_path = os.path.join('images', img_file)

    predition = predict_breed_transfer(model, img_path)
    print(predition)
    print("image_file_name: {0}, \t predition breed: {1}\n\n".format(img_path, predition))

return (predition)

views.py在ml文件夹中

from django.shortcuts import render
from .test.predict import *


def predict(request):
    pred=process()

    return render(request, "predict.html",{'pred':pred})

当我在本地计算机上运行服务器时,它会被抢占为无。 我不明白为什么views.py无法运行'predict_breed_transfer'功能...

0 个答案:

没有答案