LoginSignup
0
0

More than 5 years have passed since last update.

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

Last updated at Posted at 2017-07-16

概要

クラウドサーバでTensorFlowやってみた。
ajaxで画像アップして、戻りに画像貰うやつ。

環境

クラウド 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/test6.py',
        type: 'POST',
        data: {
            img: img
        },
        dataType: 'text',
        success: function(data) {
            var koko = document.getElementById('koko');
            koko.src = 'data:image/jpeg;base64,' + data;
        },
        error: function(res) {
            alert('err');
        }
    });
}, true);

成果物

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0