Skip to content

Instantly share code, notes, and snippets.

@cobanov
Created February 14, 2019 10:53
Show Gist options
  • Save cobanov/5db28a3c60edfc03841c8675598eee84 to your computer and use it in GitHub Desktop.
Save cobanov/5db28a3c60edfc03841c8675598eee84 to your computer and use it in GitHub Desktop.
# -*- 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.resnet50 import ResNet50
from keras.preprocessing import image
from keras.applications.resnet50 import preprocess_input, decode_predictions
import numpy as np
model = ResNet50(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])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment