Upload 2 files
Browse files- app.py +36 -0
- mnist_model.h5 +3 -0
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import numpy as np
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import matplotlib.pyplot as plt
|
| 5 |
+
from keras.datasets import mnist
|
| 6 |
+
from keras.models import load_model
|
| 7 |
+
from PIL import Image
|
| 8 |
+
|
| 9 |
+
# MNIST modelini yükleyin (önceden eğitilmiş bir model olmalı)
|
| 10 |
+
model = load_model('mnist_model.h5') # Model dosyanızın adı
|
| 11 |
+
|
| 12 |
+
# MNIST veri kümesini yükle
|
| 13 |
+
(X_train, y_train), (X_test, y_test) = mnist.load_data()
|
| 14 |
+
|
| 15 |
+
# Streamlit uygulaması
|
| 16 |
+
st.title("MNIST El Yazısı Rakam Tahmin Uygulaması")
|
| 17 |
+
|
| 18 |
+
# Kullanıcıdan bir resim yüklemesini isteyin
|
| 19 |
+
uploaded_file = st.file_uploader("Bir el yazısı rakamı resmi yükleyin...", type=["png", "jpg", "jpeg"])
|
| 20 |
+
|
| 21 |
+
if uploaded_file is not None:
|
| 22 |
+
# Resmi yükle ve göster
|
| 23 |
+
image = Image.open(uploaded_file).convert('L')
|
| 24 |
+
st.image(image, caption='Yüklenen Resim', use_column_width=True)
|
| 25 |
+
|
| 26 |
+
# Resmi işleyerek model için uygun hale getirin
|
| 27 |
+
image = image.resize((28, 28))
|
| 28 |
+
image_array = np.array(image) / 255.0 # Normalize et
|
| 29 |
+
image_array = image_array.reshape(1, 28, 28, 1) # Modelin beklediği forma getir
|
| 30 |
+
|
| 31 |
+
# Tahmin yap
|
| 32 |
+
prediction = model.predict(image_array)
|
| 33 |
+
predicted_label = np.argmax(prediction)
|
| 34 |
+
|
| 35 |
+
# Sonucu göster
|
| 36 |
+
st.write(f"Tahmin Edilen Rakam: {predicted_label}")
|
mnist_model.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fd4a4ec6114b3191a86957ea79a7466ce56d1f5ef4cc0a340c309d15a2f7d5ec
|
| 3 |
+
size 1837968
|