Metinhsimi commited on
Commit
13cef22
·
verified ·
1 Parent(s): b5a7789

Upload 3 files

Browse files
Files changed (3) hide show
  1. cifar.py +39 -0
  2. cifar_cnn_model.h5 +3 -0
  3. requirements.txt +2 -0
cifar.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ from tensorflow.keras.models import load_model
4
+ from tensorflow.keras.utils import to_categorical
5
+ from tensorflow.keras.preprocessing import image
6
+ import matplotlib.pyplot as plt
7
+
8
+ # Modeli yükle
9
+ model = load_model('cifar_cnn_model.h5') # Modelinizi kaydettiğiniz dosya adı
10
+
11
+ # CIFAR-10 sınıf isimleri
12
+ class_names = [
13
+ 'Airplane', 'Automobile', 'Bird', 'Cat', 'Deer',
14
+ 'Dog', 'Frog', 'Horse', 'Ship', 'Truck'
15
+ ]
16
+
17
+ # Streamlit uygulaması başlığı
18
+ st.title("CIFAR-10 Görüntü Sınıflandırma")
19
+
20
+ # Kullanıcıdan görüntü yüklemesini iste
21
+ uploaded_file = st.file_uploader("Bir görüntü yükleyin (32x32 boyutunda)", type=["png", "jpg", "jpeg"])
22
+
23
+ if uploaded_file is not None:
24
+ # Görüntüyü yükle ve ön işleme tabi tut
25
+ img = image.load_img(uploaded_file, target_size=(32, 32))
26
+ img_array = image.img_to_array(img) / 255.0 # Normalizasyon
27
+ img_array = np.expand_dims(img_array, axis=0) # Batch boyutu ekle
28
+
29
+ # Model ile tahmin yap
30
+ predictions = model.predict(img_array)
31
+ predicted_class = np.argmax(predictions, axis=1)
32
+
33
+ # Sonucu göster
34
+ st.image(img, caption='Yüklenen Görüntü', use_column_width=True)
35
+ st.write(f'Tahmin Edilen Sınıf: {class_names[predicted_class[0]]}')
36
+ st.write(f'Tahmin Skoru: {np.max(predictions) * 100:.2f}%')
37
+
38
+ # Uygulamayı başlatmak için terminalde şu komutu çalıştırın
39
+ # streamlit run app.py
cifar_cnn_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f07152451fd1d756a02e548ca169d4fb12a716b8e7467b1aee2c5468ffc9c93a
3
+ size 3208424
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ tensorflow
2
+ streamlit