File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 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 ("\n Lü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 ()
You can’t perform that action at this time.
0 commit comments