<jupyter_start><jupyter_text>学習済みデータの読み込み<jupyter_code>from keras.models import Sequential, model_from_json
# モデル構造の読み込み
model = model_from_json(open('./model-out/FishNary-3_model_setting.json', 'r').read())

# モデル中の各重みの読み込み
model.load_weights('./model-out/FishNary-3_model.h5')
# 読み込まれたモデル構造の確認
model.summary()<jupyter_output>_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
CNN-Conv2D-1 (Conv2D)        (None, 34, 34, 64)        15616     
_________________________________________________________________
CNN-Conv2D-2 (Conv2D)        (None, 12, 12, 64)        331840    
_________________________________________________________________
Pooling-MaxPooling2D-1 (MaxP (None, 6, 6, 64)          0         
_________________________________________________________________
Dropout-1 (Dropout)          (None, 6, 6, 64)          0         
_________________________________________________________________
CNN-Conv2D-3 (Conv2D)        (None, 6, 6, 64)          36928     
_________________________________________________________________
CNN-Conv2D-4 (Conv2D)        (None, 6, 6, 64)          36928     
_________________________________________________________________
Pooling-Ma[...]<jupyter_text>判定用の画像読み込み<jupyter_code>import numpy as np
from tensorflow.python.keras.preprocessing.image import load_img
from tensorflow.python.keras.preprocessing.image import img_to_array
# 配列の初期化
check_data = []

# 学習に使う画像の解像度を指定
resolution_x = 100
resolution_y = 100
# 判定用画像の読み込み
img_path = './images/test-madai.jpg'
#img_path = './images/test-buri.jpg'
#img_path = './images/test-hiramasa.jpg'

img = load_img(img_path, target_size=(resolution_x, resolution_y))
check_data.append(img_to_array(img)/255.)
#読み込まれた画像数を確認
len(check_data)
#読み込まれた画像の次元が学習済みモデルの次元と一致しているか確認
check_data = np.array(check_data)
print('check_data.shape : ', check_data.shape)<jupyter_output>check_data.shape :  (1, 100, 100, 3)<jupyter_text>判定実施<jupyter_code>check_result = model.predict(check_data)
# ブリ : 0       →出力例[ 0.99 , 0.05, 0.05]
# ヒラマサ : 1→出力例[ 0.05 , 0.99, 0.05]
# マダイ : 2   →出力例[ 0.05 , 0.05, 0.99]
result = check_result[0].tolist()
from decimal import *

for i in range (len(result)):
    if i == 0:
        print('ブリ        : {}'.format(Decimal(result[0]).quantize(Decimal("0.00000001"),rounding=ROUND_HALF_UP)))
    elif i == 1:
        print('ヒラマサ : {}'.format(Decimal(result[1]).quantize(Decimal("0.00000001"),rounding=ROUND_HALF_UP)))
    elif i == 2:
        print('マダイ    : {}'.format(Decimal(result[2]).quantize(Decimal("0.00000001"),rounding=ROUND_HALF_UP)))<jupyter_output>ブリ        : 0.00000424
ヒラマサ : 0.00424726
マダイ    : 0.99574858
{'fraction_non_alphanumeric': 0.14342485549132947, 'fraction_numerical': 0.06394508670520231, 'mean_word_length': 4.461538461538462, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 3, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '614958', 'license': 'Apache-2.0', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1031, 'n_words': 150, 'path': 'FishNary-checker.ipynb', 'repo_name': 'yuji901jp/FishNary', 'size': '2768'}