Django和html上的ml模型

时间:2019-11-22 00:11:43

标签: python html django machine-learning

我有 index.html

<p>input an image</p>

        <p>
            <form>  
              <input type="file" name="pic" accept="image/.jpg" onchange="loadFile(event)"></input>
              <img id="output"/>
              <script>
                    var loadFile = function(event) {
                        var output = document.getElementById('output');
                        output.src = URL.createObjectURL(event.target.files[0]);
                     };
              </script>
            </form>
        </p>

        <p>
            <form>
                <input type="submit" value="result"></input>
            </form>
        </p>

views.py

def test(request):
    if request.POST:
        d = request.POST.dict()
        img = d.get("pic")
        a=image_array(img) # convert image to array use to test model
        r=model(a) #
        return render(request, "./index.html",r)
    else:

        return render(request, "./index.html")

如何在“提交”按钮下方显示预测结果?

0 个答案:

没有答案