質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
OS

OS(オペレーティングシステム)は、システムソフトウェアの一種であり、一般的に、ハードウェアを直接的に管理・操作する最も中心的な機能を有するソフトウェアがオペレーティングシステムとして呼ばれます。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

585閲覧

python実行が終了してしまいます。

law

総合スコア12

OS

OS(オペレーティングシステム)は、システムソフトウェアの一種であり、一般的に、ハードウェアを直接的に管理・操作する最も中心的な機能を有するソフトウェアがオペレーティングシステムとして呼ばれます。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2020/09/15 10:25

python

1import os 2from flask import Flask, request, redirect, url_for,flash 3from werkzeug.utils import secure_filename 4 5from keras.models import Sequential, load_model 6import keras,sys 7import numpy as np 8from PIL import Image 9 10classes = ["matsumoto_hitoshi","nakazima_ishireri"] 11num_classes = len(classes) 12image_size = 50 13 14UPLOAD_FOLDER = './uploads' 15ALLOWED_EXTENSIONS = set(['png', 'jpg', 'gif']) 16 17app = Flask(__name__) 18app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER 19app.secret_key = "super secret key" 20 21 22 23def allowed_file(filename): 24 return '.' in filename and filename.rsplit('.',1)[1].lower() in ALLOWED_EXTENSIONS 25 26@app.route('/', methods=['GET', 'POST']) 27def upload_file(): 28 if request.method == 'POST': 29 if 'file' not in request.files: 30 flash('ファイルがありません') 31 return redirect(request.url) 32 file = request.files['file'] 33 if file.filename == '': 34 flash('ファイルがありません') 35 return redirect(request.url) 36 if file and allowed_file(file.filename): 37 filename = secure_filename(file.filename) 38 file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) 39 filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename) 40 41 model = load_model('./face_cnn.h5') 42 43 image = Image.open(filepath) 44 image = image.convert('RGB') 45 image = image.resize((image_size, image_size)) 46 data = np.asarray(image) 47 X = [] 48 X.append(data) 49 X = np.array(X) 50 51 result = model.predict([X])[0] 52 predicted = result.argmax() 53 percentage = int(result[predicted] * 100) 54 55 return "ラベル: " + classes[predicted] + ", 確率:"+ str(percentage) + " %" 56 57 58 #return redirect(url_for('uploaded_file', filename=filename)) 59 return ''' 60 <!doctype html> 61 <html> 62 <head> 63 <meta charset="UTF-8"> 64 <title>ファイルをアップロードして判定しよう</title></head> 65 <body> 66 <h1>ファイルをアップロードして判定しよう!</h1> 67 <form method = post enctype = multipart/form-data> 68 <p><input type=file name=file> 69 <input type=submit value=Upload> 70 </form> 71 </body> 72 </html> 73 ''' 74 75from flask import send_from_directory 76 77@app.route('/uploads/<filename>') 78def uploaded_file(filename): 79 return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
Using TensorFlow backend. C:\Users\my174\anaconda3\envs\kaohanbetsu_for_exam\lib\site-packages\tensorflow\python\framework\dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint8 = np.dtype([("qint8", np.int8, 1)]) C:\Users\my174\anaconda3\envs\kaohanbetsu_for_exam\lib\site-packages\tensorflow\python\framework\dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) C:\Users\my174\anaconda3\envs\kaohanbetsu_for_exam\lib\site-packages\tensorflow\python\framework\dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint16 = np.dtype([("qint16", np.int16, 1)]) C:\Users\my174\anaconda3\envs\kaohanbetsu_for_exam\lib\site-packages\tensorflow\python\framework\dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) C:\Users\my174\anaconda3\envs\kaohanbetsu_for_exam\lib\site-packages\tensorflow\python\framework\dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint32 = np.dtype([("qint32", np.int32, 1)]) C:\Users\my174\anaconda3\envs\kaohanbetsu_for_exam\lib\site-packages\tensorflow\python\framework\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. np_resource = np.dtype([("resource", np.ubyte, 1)]) C:\Users\my174\anaconda3\envs\kaohanbetsu_for_exam\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint8 = np.dtype([("qint8", np.int8, 1)]) C:\Users\my174\anaconda3\envs\kaohanbetsu_for_exam\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) C:\Users\my174\anaconda3\envs\kaohanbetsu_for_exam\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint16 = np.dtype([("qint16", np.int16, 1)]) C:\Users\my174\anaconda3\envs\kaohanbetsu_for_exam\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) C:\Users\my174\anaconda3\envs\kaohanbetsu_for_exam\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint32 = np.dtype([("qint32", np.int32, 1)]) C:\Users\my174\anaconda3\envs\kaohanbetsu_for_exam\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. np_resource = np.dtype([("resource", np.ubyte, 1)])

実行環境は
windowsos
vscode
python 3.7.8です

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

bsdfan

2020/09/17 22:44

どうやって実行していますか? app.run() がないので、wsgiサーバー(gunicornとか)から呼び出すなどしないといけないです。
guest

回答1

0

自己解決

ただflaskでサーバーを起動するのを忘れてただけでした。

投稿2020/09/18 14:44

law

総合スコア12

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問