Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import numpy as np | |
| import tensorflow as tf | |
| from tensorflow.keras.models import load_model | |
| from PIL import Image | |
| import io | |
| # Modeli yükle | |
| model = load_model('model.h5') | |
| # Fashion MNIST etiketleri | |
| class_names = [ | |
| 'T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', | |
| 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot' | |
| ] | |
| # Uygulama başlığı | |
| st.title("Fashion MNIST Tahmin Uygulaması") | |
| # Kullanıcıdan resim yüklemesini iste | |
| st.sidebar.header("Resim Yükle") | |
| uploaded_file = st.sidebar.file_uploader("Bir resim dosyası yükleyin", type=["jpg", "jpeg", "png"]) | |
| # Resmi işler ve tahmin yap | |
| if uploaded_file is not None: | |
| # Resmi yükle | |
| image = Image.open(uploaded_file) | |
| # Resmi 28x28 boyutuna getir ve gri tonlamaya çevir | |
| image = image.resize((28, 28)).convert('L') | |
| image = np.array(image) | |
| # Resmi normalize et | |
| image = image / 255.0 | |
| # Resmi uygun şekle getir | |
| image = image.reshape(1, 28, 28, 1) | |
| # Tahmin yap | |
| if st.button("Tahmin Et"): | |
| prediction = model.predict(image) | |
| predicted_class = np.argmax(prediction) | |
| # Tahmin sonucunu göster | |
| st.subheader("Tahmin Edilen Etiket:") | |
| st.write(class_names[predicted_class]) | |
| # Yüklenen resmi göster | |
| st.image(image.reshape(28, 28), caption="Yüklenen Resim", use_column_width=True) |