Skip to content

Commit 0c08025

Browse files
authored
Add files via upload
1 parent a453839 commit 0c08025

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

nesne_hayvan_tanıma.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#keras içerisindeki inception hazır modeliyle resimlerden nesne ve hayvan tanıma
2+
from keras.applications.inception_v3 import InceptionV3
3+
from keras.applications.inception_v3 import preprocess_input
4+
from keras.applications.inception_v3 import decode_predictions
5+
from keras.preprocessing import image
6+
import numpy as np
7+
import matplotlib.pyplot as plt
8+
import os
9+
10+
model = InceptionV3(weights='imagenet', include_top=True)
11+
konum = str(input("\nLütfen fotoğrafların olduğu klasör yolunu giriniz: "))
12+
dosyalar = os.listdir(konum)
13+
for i in range(1, (len(dosyalar)+1)):
14+
img_path = "{}/{}".format(konum ,dosyalar[i-1])
15+
16+
img = image.load_img(img_path, target_size=(299, 299))
17+
x = image.img_to_array(img)
18+
x = np.expand_dims(x, axis = 0)
19+
x = preprocess_input(x)
20+
21+
features = model.predict(x)
22+
print("\n{} resmi için ilk 3 tahmin:\n".format(dosyalar[i-1]), decode_predictions(features, top = 3))
23+
24+
plt.imshow(image.load_img(img_path))
25+
plt.title("{}".format(decode_predictions(features, top = 1)))
26+
plt.show()

0 commit comments

Comments
 (0)