Skip to content

Instantly share code, notes, and snippets.

@cobanov
Created February 14, 2019 09:58
Show Gist options
  • Save cobanov/b28cf8f6763c2c818a820b75ed320906 to your computer and use it in GitHub Desktop.
Save cobanov/b28cf8f6763c2c818a820b75ed320906 to your computer and use it in GitHub Desktop.
VGG16 Keras
# -*- coding: utf-8 -*-
"""
Deep Learning Türkiye topluluğu için Mert Çobanoğlu tarafından hazırlanmıştır.
Amaç: Keras ile nesne tanıma.
Algoritma: Evrişimli Sinir Ağları (Convolutional Neural Networks)
Ek: Çalışma ile ilgili rehber README.md dosyasında belirtilmiştir.
"""
from keras.applications.vgg16 import VGG16
from keras.preprocessing import image
from keras.applications.vgg16 import preprocess_input, decode_predictions
import numpy as np
model = VGG16(weights='imagenet')
img_path = 'images/bird.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
preds = model.predict(x)
print('Predicted:', decode_predictions(preds, top=3)[0])
@acsgn95
Copy link

acsgn95 commented Apr 10, 2021

model = VGG16(weights='imagenet') ======> model = VGG16(weights='imagenet', include_top=True)
#Üstteki değişikliği yapın#
print('Predicted:', decode_predictions(preds, top=3)[0])
#burada hata almazsınız#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment