File size: 1,157 Bytes
2412486
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import numpy as np
import tensorflow as tf
from PIL import Image

# Modeli yükleme
model = tf.keras.models.load_model('model.keras')

# Sınıf isimleri
class_names = [
    'T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',
    'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot'
]

# Uygulama başlığı
st.title('Fashion MNIST Modeli ile Tahmin')

# Kullanıcıdan resim yükleme
uploaded_file = st.file_uploader("Bir resim yükleyin (28x28 boyutunda, gri tonlamalı)", type=["png", "jpg", "jpeg"])

if uploaded_file is not None:
    # Resmi yükleme ve ön işleme
    image = Image.open(uploaded_file).convert('L')  # Gri tonlamalı
    image = image.resize((28, 28))
    image_array = np.array(image)
    image_array = image_array.astype('float32') / 255.0
    image_array = image_array.reshape(1, 28, 28)  # Modelin beklediği şekil

    # Tahmin yapma
    predictions = model.predict(image_array)
    predicted_class = np.argmax(predictions, axis=1)

    # Sonuçları gösterme
    st.image(image, caption='Yüklenen Resim', use_column_width=True)
    st.write(f'Tahmin Edilen Sınıf: {class_names[predicted_class[0]]}')