クラウドサーバでTensorFlow その11


概要

クラウドサーバでTensorFlowやってみた。
tensorflowのinceptionで1000分類してみた。
ローカルファイルに、対応してみた。

環境

クラウド idcf
linux debian-8.11
tensorflow 1.2
gpu 無し

写真

サンプルコード

var uploadFile;
document.getElementById('imageFile').addEventListener("change", function() {
    var image = new Image();
    var reader = new FileReader();
    reader.onload = function(e) {
        canvas = document.getElementById('canv_original');
        canvas.width = 224;
        canvas.height = 224;
        ctx = canvas.getContext("2d");
        image.onload = function() {
            ctx.drawImage(image, 0, 0, 224, 224);
        }
        image.src = reader.result;
    };
    uploadFile = this.files[0];
    reader.readAsDataURL(uploadFile);
}, true);
document.getElementById('upload').addEventListener("click", function() {
    var img = canvas.toDataURL('image/jpeg');
    $.ajax({
        url: 'http:///cgi-bin/test5.py',
        type: 'POST',
        data: {
            img: img
        },
        dataType: 'json',
        success: function(data) {
            if (data.status)
            {
                $('#report').html('This is ' + data.num + '.');
            }
            else
            {
                $('#report').html('これは、分かりません');
            }
        },
        error: function(res) {
            alert('err');
        }
    });
}, true);


成果物