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