top-5
top-k
metric의 특정 케이스https://developer.ridgerun.com/wiki/images/thumb/e/eb/Googlenet.png/2700px-Googlenet.png
🔸 특징
padding="SAME"
이며 stride=1
, 활성화 함수는 ReLU
사용🔸 기여
https://miro.medium.com/max/1400/1*6hF97Upuqg_LdsqWY6n_wg.png
https://blog.kakaocdn.net/dn/HTvh9/btqChF66iqJ/IJaCThdcNkzDtmicsrsL0k/img.png
!wget -O dog.jpg https://www.publicdomainpictures.net/pictures/250000/nahled/dog-beagle-portrait.jpg
!wget -O fish.jpg https://upload.wikimedia.org/wikipedia/commons/7/7a/Goldfish_1.jpg
!wget -O bee.jpg https://upload.wikimedia.org/wikipedia/commons/4/4d/Apis_mellifera_Western_honey_bee.jpg
!wget -O beaver.jpg https://upload.wikimedia.org/wikipedia/commons/6/6b/American_Beaver.jpg
!wget -O crane.jpg https://p1.pxfuel.com/preview/42/50/534/europe-channel-crane-harbour-crane-harbour-cranes-cranes-transport.jpg
!wget -O zebra.jpg https://upload.wikimedia.org/wikipedia/commons/f/f0/Zebra_standing_alone_crop.jpg
import numpy as np
import tensorflow as tf
from keras.applications import vgg19
from keras.applications import inception_v3
from keras.applications import resnet
from keras.applications import xception
from keras.applications import densenet
from keras.applications import mobilenet
vgg19_m = vgg19.VGG19(include_top=True, weights='imagenet',
input_tensor=None, input_shape=None,
pooling=None, classes=1000)
inception_m = inception_v3.InceptionV3(include_top=True, weights='imagenet',
input_tensor=None, input_shape=None,
pooling=None, classes=1000)
resnet_m = resnet.ResNet50(include_top=True, weights='imagenet',
input_tensor=None, input_shape=None,
pooling=None, classes=1000)
xception_m = xception.Xception(include_top=True, weights='imagenet',
input_tensor=None, input_shape=None,
pooling=None, classes=1000)
densenet_m = densenet.DenseNet201(include_top=True, weights='imagenet',
input_tensor=None, input_shape=None,
pooling=None, classes=1000)
mobilenet_m = mobilenet.MobileNet(include_top=True, weights='imagenet',
input_tensor=None, input_shape=None,
pooling=None, classes=1000)
def predict_pictures(model_name,module_name):
li = ['dog','fish','bee','beaver','crane','zebra']
result = []
for i in li:
if model_name in [inception_m,xception_m]:
target_size = (299,299)
else:
target_size = (224,224)
img = tf.keras.preprocessing.image.load_img(f'{i}.jpg', target_size = target_size)
x = tf.keras.preprocessing.image.img_to_array(img)
x = x.reshape(1, x.shape[0], x.shape[1], x.shape[2])
x = module_name.preprocess_input(x)
preds = model_name.predict(x)
decode = module_name.decode_predictions(preds)
result.append(decode[0][0][2])
return result
import pandas as pd
model_li = [vgg19_m,inception_m,resnet_m,xception_m,densenet_m,mobilenet_m]
module_li = [vgg19,inception_v3,resnet,xception,densenet,mobilenet]
final = pd.DataFrame(columns = ['dog','fish','bee','beaver','crane','zebra'])
for i,m in enumerate(model_li):
final.loc[m.name] = predict_pictures(m,module_li[i])
final['mean'] = final.mean(axis=1)
final.sort_values(by='mean')
** 이미지출처