機械学習4日目
5184 ワード
作成したモデルのバインド

このクリップにサーバを作成するには
サーバ

Webappでhtmlを作成する

<!DOCTYPE html>
<body>
<form action = "" method="post" enctype="multipart/form-data">
<input type = "file" name="uploadImage">
<input type = "submit" value="분석하기">
</form>
</body>
jspファイルを作成して結果を検証
jupyter
フラスコを設置して分析用サーバーを構築
!pip install flask
from flask import Flask, request, Response, redirect
フラスコオブジェクトの作成(検証用)
app = Flask(__name__)
@app.route('/', methods=['GET','POST'])
def index() :
return "hello world"
app.run()

htmlにアドレスを入れる動作



解析後にjspファイルに送信するように変更
@app.route('/', methods=['GET','POST'])
def index() :
return return redirect("http://localhost:8081/upload/result.jsp")
画像解析
htmlの変更

以上のソースからmtplotlibをインストール
!pip install flask
!pip install matplotlib
importの変更
from flask import Flask, request, Response, redirect
import io
import numpy as np
import matplotlib.pyplot as plt
io:Python I/Oをサポートするライブラリ関数の変更
@app.route('/predict', methods=['GET','POST'])
def predict() :
if request.method =='POST' :
img = request.files['uploadImage']
input_stream = io.NytesIO()
img.save(input_stream)
data = np.fromstring(input_stream.getvalue(),
dtype=np.uint8)
return redirect("http://localhost:8081/upload/result.jsp")
:バイト単位で読み出すチャネル
:ファイルからデータを読み込む
dtype=np.uint8)
:読み出したデータをnpに変更し、データ変数に
Reference
この問題について(機械学習4日目), 我々は、より多くの情報をここで見つけました https://velog.io/@dfdf/머신러닝4일차-a1l9sgduテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol