MSK34's picture
Update src/streamlit_app.py
55355a1 verified
Raw
History Blame Contribute Delete
1.21 kB
# Fashion MNIST CNN modeli ile kıyafet sınıflandırma uygulaması oluşturuyoruz.
import streamlit as st
import tensorflow as tf
import numpy as np
from PIL import Image
st.title("Fashion MNIST Image Classification")
st.write(
"Bu uygulama, yüklenen kıyafet görselini CNN modeli ile sınıflandırır."
)
# Eğitilmiş modeli yüklüyoruz.
model = tf.keras.models.load_model("src/fashion_mnist_cnn.h5")
# Sınıf isimlerini tanımlıyoruz.
class_names = [
"T-shirt",
"Trouser",
"Pullover",
"Dress",
"Coat",
"Sandal",
"Shirt",
"Sneaker",
"Bag",
"Ankle Boot"
]
# Kullanıcıdan görsel alıyoruz.
uploaded_file = st.file_uploader(
"Bir kıyafet görseli yükleyin",
type=["png", "jpg", "jpeg"]
)
if uploaded_file is not None:
img = Image.open(uploaded_file).convert("L")
st.image(img, caption="Yüklenen Görsel", width=300)
img = img.resize((28, 28))
img_array = np.array(img)
img_array = img_array / 255.0
img_array = img_array.reshape(1, 28, 28, 1)
prediction = model.predict(img_array)
class_index = np.argmax(prediction)
st.subheader("Tahmin Sonucu")
st.success(class_names[class_index])