Spaces:
Sleeping
Sleeping
| import os | |
| import streamlit as st | |
| import tensorflow as tf | |
| import numpy as np | |
| from PIL import Image | |
| # Uyarıları sustur | |
| os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' | |
| # Modeli yükle | |
| model = tf.keras.models.load_model("mnist_augmented_model.keras") | |
| st.title("🧠 MNIST Görüntü Artırma ve Tahmin") | |
| uploaded_file = st.file_uploader("28x28 boyutunda bir el yazısı rakam görseli yükleyin", type=["png", "jpg", "jpeg"]) | |
| if uploaded_file is not None: | |
| image = Image.open(uploaded_file).convert("L").resize((28, 28)) | |
| st.image(image, caption="Orijinal Görsel", width=150) | |
| img_array = np.array(image).astype("float32") / 255.0 | |
| img_array = np.expand_dims(img_array, axis=-1) | |
| img_array = np.expand_dims(img_array, axis=0) | |
| def augment(image): | |
| image = tf.image.random_flip_left_right(image) | |
| image = tf.image.random_brightness(image, max_delta=0.1) | |
| image = tf.image.random_contrast(image, 0.8, 1.2) | |
| return image | |
| augmented = augment(tf.convert_to_tensor(img_array[0])).numpy() | |
| st.image([img_array[0].squeeze(), augmented.squeeze()], caption=["Orijinal", "Artırılmış"], width=150) | |
| prediction = model.predict(img_array) | |
| predicted_class = np.argmax(prediction) | |
| st.success(f"Modelin Tahmini: {predicted_class}") |